| Index: trunk/phase3/docs/hooks.txt |
| — | — | @@ -595,6 +595,10 @@ |
| 596 | 596 | &$scalerParams: Array with scaler parameters |
| 597 | 597 | &$mto: null, set to a MediaTransformOutput |
| 598 | 598 | |
| | 599 | +'PerformRetroactiveAutoblock': called before a retroactive autoblock is applied to a user |
| | 600 | +$block: Block object (which is set to be autoblocking) |
| | 601 | +&$blockIds: Array of block IDs of the autoblock |
| | 602 | + |
| 599 | 603 | 'BlockIp': before an IP address or user is blocked |
| 600 | 604 | $block: the Block object about to be saved |
| 601 | 605 | $user: the user _doing_ the block (not the one being blocked) |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -3261,14 +3261,6 @@ |
| 3262 | 3262 | ); |
| 3263 | 3263 | |
| 3264 | 3264 | /** |
| 3265 | | - * Functions to handle autoblocking users. The default handlers will be used |
| 3266 | | - * where null is given. They can otherwise be overridden with custom callbacks. |
| 3267 | | - * |
| 3268 | | - * 'retroactiveAutoblock' handlers must return the array of autoblock IDs |
| 3269 | | - */ |
| 3270 | | -$wgAutoblockHandlers = array( 'retroactiveAutoblock' => null ); |
| 3271 | | - |
| 3272 | | -/** |
| 3273 | 3265 | * If true, blocked users will not be allowed to login. When using this with |
| 3274 | 3266 | * a public wiki, the effect of logging out blocked users may actually be |
| 3275 | 3267 | * avers: unless the user's address is also blocked (e.g. auto-block), |
| Index: trunk/phase3/includes/Block.php |
| — | — | @@ -486,27 +486,18 @@ |
| 487 | 487 | * @return Array: block IDs of retroactive autoblocks made |
| 488 | 488 | */ |
| 489 | 489 | protected function doRetroactiveAutoblock() { |
| 490 | | - global $wgAutoblockHandlers; |
| 491 | | - |
| 492 | 490 | $blockIds = array(); |
| 493 | 491 | # If autoblock is enabled, autoblock the LAST IP(s) used |
| 494 | 492 | if ( $this->isAutoblocking() && $this->getType() == self::TYPE_USER ) { |
| 495 | 493 | wfDebug( "Doing retroactive autoblocks for " . $this->getTarget() . "\n" ); |
| 496 | 494 | |
| 497 | | - $call = isset( $wgAutoblockHandlers['retroactiveAutoblock'] ) |
| 498 | | - ? $wgAutoblockHandlers['retroactiveAutoblock'] |
| 499 | | - : null; // default |
| | 495 | + $continue = wfRunHooks( |
| | 496 | + 'PerformRetroactiveAutoblock', array( $this, &$blockIds ) ); |
| 500 | 497 | |
| 501 | | - if ( is_callable( $call ) ) { // custom handler |
| 502 | | - $blockIds = MWFunction::call( $call, $this ); |
| 503 | | - } else { // regular handler |
| 504 | | - if ( $call !== null ) { // something given, but bad |
| 505 | | - wfWarn( 'doRetroactiveAutoblock given uncallable handler, check $wgAutoblockHandlers; using default handler.' ); |
| 506 | | - } |
| 507 | | - $blockIds = self::defaultRetroactiveAutoblock( $this ); |
| | 498 | + if ( $continue ) { |
| | 499 | + self::defaultRetroactiveAutoblock( $this, $blockIds ); |
| 508 | 500 | } |
| 509 | 501 | } |
| 510 | | - |
| 511 | 502 | return $blockIds; |
| 512 | 503 | } |
| 513 | 504 | |
| — | — | @@ -514,9 +505,11 @@ |
| 515 | 506 | * Retroactively autoblocks the last IP used by the user (if it is a user) |
| 516 | 507 | * blocked by this Block. This will use the recentchanges table. |
| 517 | 508 | * |
| | 509 | + * @param Block $block |
| | 510 | + * @param Array &$blockIds |
| 518 | 511 | * @return Array: block IDs of retroactive autoblocks made |
| 519 | 512 | */ |
| 520 | | - protected static function defaultRetroactiveAutoblock( Block $block ) { |
| | 513 | + protected static function defaultRetroactiveAutoblock( Block $block, array &$blockIds ) { |
| 521 | 514 | $dbr = wfGetDB( DB_SLAVE ); |
| 522 | 515 | |
| 523 | 516 | $options = array( 'ORDER BY' => 'rc_timestamp DESC' ); |
| — | — | @@ -539,8 +532,6 @@ |
| 540 | 533 | } |
| 541 | 534 | } |
| 542 | 535 | } |
| 543 | | - |
| 544 | | - return $blockIds; |
| 545 | 536 | } |
| 546 | 537 | |
| 547 | 538 | /** |
| Index: trunk/extensions/CheckUser/CheckUser.php |
| — | — | @@ -68,6 +68,9 @@ |
| 69 | 69 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'CheckUserHooks::checkUserSchemaUpdates'; |
| 70 | 70 | $wgHooks['ContributionsToolLinks'][] = 'CheckUserHooks::loadCheckUserLink'; |
| 71 | 71 | |
| | 72 | +# Take over autoblocking |
| | 73 | +$wgHooks['PerformRetroactiveAutoblock'][] = 'CheckUserHooks::doRetroactiveAutoblock'; |
| | 74 | + |
| 72 | 75 | $wgResourceModules['ext.checkUser'] = array( |
| 73 | 76 | 'scripts' => 'checkuser.js', |
| 74 | 77 | 'dependencies' => array( 'mediawiki.util' ), // IP stuff |
| Index: trunk/extensions/CheckUser/CheckUser.hooks.php |
| — | — | @@ -362,9 +362,10 @@ |
| 363 | 363 | * Retroactively autoblocks the last IP used by the user (if it is a user) |
| 364 | 364 | * blocked by this Block. |
| 365 | 365 | * |
| 366 | | - * @return Array: block IDs of retroactive autoblocks made |
| | 366 | + * @param Block $block |
| | 367 | + * @param Array &$blockIds |
| 367 | 368 | */ |
| 368 | | - public static function doRetroactiveAutoblock( Block $block ) { |
| | 369 | + public static function doRetroactiveAutoblock( Block $block, array &$blockIds ) { |
| 369 | 370 | $dbr = wfGetDB( DB_SLAVE ); |
| 370 | 371 | |
| 371 | 372 | $user = User::newFromName( (string)$block->getTarget(), false ); |
| — | — | @@ -390,6 +391,6 @@ |
| 391 | 392 | } |
| 392 | 393 | } |
| 393 | 394 | |
| 394 | | - return $blockIds; |
| | 395 | + return false; // autoblock handled |
| 395 | 396 | } |
| 396 | 397 | } |