From: Aaron Schulz Date: Fri, 15 Jul 2011 00:48:02 +0000 (+0000) Subject: Follow-up r92220: changed autoblock handling to use PerformRetroactiveAutoblock hook... X-Git-Tag: 1.31.0-rc.0~28833 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=4a1b848c58a8da55872dfac6971a43aae3571016;p=lhc%2Fweb%2Fwiklou.git Follow-up r92220: changed autoblock handling to use PerformRetroactiveAutoblock hook instead of a global. Also made CheckUser always override autoblocks (no config). --- diff --git a/docs/hooks.txt b/docs/hooks.txt index f2b5101095..9174351f85 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -595,6 +595,10 @@ $image: File &$scalerParams: Array with scaler parameters &$mto: null, set to a MediaTransformOutput +'PerformRetroactiveAutoblock': called before a retroactive autoblock is applied to a user +$block: Block object (which is set to be autoblocking) +&$blockIds: Array of block IDs of the autoblock + 'BlockIp': before an IP address or user is blocked $block: the Block object about to be saved $user: the user _doing_ the block (not the one being blocked) diff --git a/includes/Block.php b/includes/Block.php index e3bb0c48a0..ba875fa8bf 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -486,27 +486,18 @@ class Block { * @return Array: block IDs of retroactive autoblocks made */ protected function doRetroactiveAutoblock() { - global $wgAutoblockHandlers; - $blockIds = array(); # If autoblock is enabled, autoblock the LAST IP(s) used if ( $this->isAutoblocking() && $this->getType() == self::TYPE_USER ) { wfDebug( "Doing retroactive autoblocks for " . $this->getTarget() . "\n" ); - $call = isset( $wgAutoblockHandlers['retroactiveAutoblock'] ) - ? $wgAutoblockHandlers['retroactiveAutoblock'] - : null; // default + $continue = wfRunHooks( + 'PerformRetroactiveAutoblock', array( $this, &$blockIds ) ); - if ( is_callable( $call ) ) { // custom handler - $blockIds = MWFunction::call( $call, $this ); - } else { // regular handler - if ( $call !== null ) { // something given, but bad - wfWarn( 'doRetroactiveAutoblock given uncallable handler, check $wgAutoblockHandlers; using default handler.' ); - } - $blockIds = self::defaultRetroactiveAutoblock( $this ); + if ( $continue ) { + self::defaultRetroactiveAutoblock( $this, $blockIds ); } } - return $blockIds; } @@ -514,9 +505,11 @@ class Block { * Retroactively autoblocks the last IP used by the user (if it is a user) * blocked by this Block. This will use the recentchanges table. * + * @param Block $block + * @param Array &$blockIds * @return Array: block IDs of retroactive autoblocks made */ - protected static function defaultRetroactiveAutoblock( Block $block ) { + protected static function defaultRetroactiveAutoblock( Block $block, array &$blockIds ) { $dbr = wfGetDB( DB_SLAVE ); $options = array( 'ORDER BY' => 'rc_timestamp DESC' ); @@ -539,8 +532,6 @@ class Block { } } } - - return $blockIds; } /** diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 422cb4df01..3ddddd72a9 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3260,14 +3260,6 @@ $wgBlockCIDRLimit = array( 'IPv6' => 64, # 2^64 = ~1.8x10^19 addresses ); -/** - * Functions to handle autoblocking users. The default handlers will be used - * where null is given. They can otherwise be overridden with custom callbacks. - * - * 'retroactiveAutoblock' handlers must return the array of autoblock IDs - */ -$wgAutoblockHandlers = array( 'retroactiveAutoblock' => null ); - /** * If true, blocked users will not be allowed to login. When using this with * a public wiki, the effect of logging out blocked users may actually be