* last-hit counters will be shared across wikis.
*
* @param string $action Action to enforce; 'edit' if unspecified
+ * @param integer $incrBy Positive amount to increment counter by [defaults to 1]
* @return bool True if a rate limiter was tripped
*/
- public function pingLimiter( $action = 'edit' ) {
+ public function pingLimiter( $action = 'edit', $incrBy = 1 ) {
// Call the 'PingLimiter' hook
$result = false;
- if ( !wfRunHooks( 'PingLimiter', array( &$this, $action, &$result ) ) ) {
+ if ( !wfRunHooks( 'PingLimiter', array( &$this, $action, &$result, $incrBy ) ) ) {
return $result;
}
}
} else {
wfDebug( __METHOD__ . ": adding record for $key $summary\n" );
- $wgMemc->add( $key, 0, intval( $period ) ); // first ping
+ if ( $incrBy > 0 ) {
+ $wgMemc->add( $key, 0, intval( $period ) ); // first ping
+ }
+ }
+ if ( $incrBy > 0 ) {
+ $wgMemc->incr( $key, $incrBy );
}
- $wgMemc->incr( $key );
}
wfProfileOut( __METHOD__ );
return $this->mLocked;
}
global $wgAuth;
+ StubObject::unstub( $wgAuth );
$authUser = $wgAuth->getUserInstance( $this );
$this->mLocked = (bool)$authUser->isLocked();
return $this->mLocked;
$this->getBlockedStatus();
if ( !$this->mHideName ) {
global $wgAuth;
+ StubObject::unstub( $wgAuth );
$authUser = $wgAuth->getUserInstance( $this );
$this->mHideName = (bool)$authUser->isHidden();
}
* the next change of the page if it's watched etc.
* @note If the user doesn't have 'editmywatchlist', this will do nothing.
* @param $title Title of the article to look at
+ * @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
*/
- public function clearNotification( &$title ) {
+ public function clearNotification( &$title, $oldid = 0 ) {
global $wgUseEnotif, $wgShowUpdatedMarker;
// Do nothing if the database is locked to writes
return;
}
- if ( $title->getNamespace() == NS_USER_TALK &&
- $title->getText() == $this->getName() ) {
- if ( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) ) {
+ // If we're working on user's talk page, we should update the talk page message indicator
+ if ( $title->getNamespace() == NS_USER_TALK && $title->getText() == $this->getName() ) {
+ if ( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this, $oldid ) ) ) {
return;
}
- $this->setNewtalk( false );
+
+ $nextid = $oldid ? $title->getNextRevisionID( $oldid ) : null;
+
+ if ( !$oldid || !$nextid ) {
+ // If we're looking at the latest revision, we should definitely clear it
+ $this->setNewtalk( false );
+ } else {
+ // Otherwise we should update its revision, if it's present
+ if ( $this->getNewtalk() ) {
+ // Naturally the other one won't clear by itself
+ $this->setNewtalk( false );
+ $this->setNewtalk( true, Revision::newFromId( $nextid ) );
+ }
+ }
}
if ( !$wgUseEnotif && !$wgShowUpdatedMarker ) {
$force = 'force';
}
- $this->getWatchedItem( $title )->resetNotificationTimestamp( $force );
+ $this->getWatchedItem( $title )->resetNotificationTimestamp( $force, $oldid );
}
/**
if ( $id != 0 ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'watchlist',
- array( /* SET */
- 'wl_notificationtimestamp' => null
- ), array( /* WHERE */
- 'wl_user' => $id
- ), __METHOD__
+ array( /* SET */ 'wl_notificationtimestamp' => null ),
+ array( /* WHERE */ 'wl_user' => $id ),
+ __METHOD__
);
- # We also need to clear here the "you have new message" notification for the own user_talk page
- # This is cleared one page view later in Article::viewUpdates();
+ // We also need to clear here the "you have new message" notification for the own user_talk page;
+ // it's cleared one page view later in WikiPage::doViewUpdates().
}
}