&$result : Whether or not the action should be prevented
Change $result and return false to give a definitive answer, otherwise
the built-in rate limiting checks are used, if enabled.
+$incrBy: Amount to increment counter by
'PlaceNewSection': Override placement of new sections. Return false and put the
merged text into $text to override the default behavior.
'emailuser' => array(
'user' => null,
),
+ 'linkpurge' => array(
+ 'anon' => null,
+ 'user' => null,
+ 'newbie' => null,
+ 'ip' => null,
+ 'subnet' => null,
+ ),
);
/**
wfProfileOut( __METHOD__ );
return $status;
}
- if ( $wgUser->pingLimiter() ) {
+ if ( $wgUser->pingLimiter() || $wgUser->pingLimiter( 'linkpurge', 0 ) ) {
$status->fatal( 'actionthrottledtext' );
$status->value = self::AS_RATE_LIMITED;
wfProfileOut( __METHOD__ . '-checks' );
}
$result['nullEdit'] = $doEditStatus->hasMessage( 'edit-no-change' );
+ if ( $result['nullEdit'] ) {
+ // We don't know if it was a null edit until now, so increment here
+ $wgUser->pingLimiter( 'linkpurge' );
+ }
$result['redirect'] = $content->isRedirect();
$this->updateWatchlist();
wfProfileOut( __METHOD__ );
* 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__ );
$r['purged'] = '';
if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
- if ( !$this->getUser()->pingLimiter() ) {
+ if ( !$this->getUser()->pingLimiter( 'linkpurge' ) ) {
global $wgEnableParserCache;
$popts = $page->makeParserOptions( 'canonical' );