From: Aaron Schulz Date: Tue, 22 Mar 2011 11:51:09 +0000 (+0000) Subject: Fixed daft error in r84523 so "angry" autoblocks work again X-Git-Tag: 1.31.0-rc.0~31253 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=f6e0bc93243885586ff39e0e896f28c7166459df;p=lhc%2Fweb%2Fwiklou.git Fixed daft error in r84523 so "angry" autoblocks work again --- diff --git a/includes/Block.php b/includes/Block.php index af28185fdc..d1619e9fad 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -488,13 +488,14 @@ class Block { * block (same name and options) already in the database. * * @return mixed: false on failure, assoc array on success: - * ('id' => block ID, 'autoId' => autoblock ID or false) + * ('id' => block ID, 'autoIds' => array of autoblock IDs) */ public function insert( $dbw = null ) { wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" ); - if ( $dbw === null ) + if ( $dbw === null ) { $dbw = wfGetDB( DB_MASTER ); + } $this->validateBlockParams(); $this->initialiseRange(); @@ -530,8 +531,8 @@ class Block { $affected = $dbw->affectedRows(); if ( $affected ) { - $auto_ipd_id = $this->doRetroactiveAutoblock(); - return array( 'id' => $ipb_id, 'autoId' => $auto_ipd_id ); + $auto_ipd_ids = $this->doRetroactiveAutoblock(); + return array( 'id' => $ipb_id, 'autoIds' => $auto_ipd_ids ); } return false; @@ -607,9 +608,11 @@ class Block { * Retroactively autoblocks the last IP used by the user (if it is a user) * blocked by this Block. * - * @return mixed: block ID if a retroactive autoblock was made, false if not. + * @return Array: block IDs of retroactive autoblocks made */ protected function doRetroactiveAutoblock() { + $blockIds = array(); + $dbr = wfGetDB( DB_SLAVE ); # If autoblock is enabled, autoblock the LAST IP used # - stolen shamelessly from CheckUser_body.php @@ -622,7 +625,8 @@ class Block { if ( $this->mAngryAutoblock ) { // Block any IP used in the last 7 days. Up to five IPs. - $conds[] = 'rc_timestamp < ' . $dbr->addQuotes( $dbr->timestamp( time() - ( 7 * 86400 ) ) ); + $conds[] = 'rc_timestamp < ' . + $dbr->addQuotes( $dbr->timestamp( time() - ( 7 * 86400 ) ) ); $options['LIMIT'] = 5; } else { // Just the last IP used. @@ -638,12 +642,13 @@ class Block { } else { foreach ( $res as $row ) { if ( $row->rc_ip ) { - return $this->doAutoblock( $row->rc_ip ); + $id = $this->doAutoblock( $row->rc_ip ); + if ( $id ) $blockIds[] = $id; } } } } - return false; + return $blockIds; } /** diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 49aab22c06..504efde970 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -623,10 +623,7 @@ class SpecialBlock extends SpecialPage { $logParams ); # Relate log ID to block IDs (bug 25763) - $blockIds = array( $status['id'] ); // main block - if ( $status['autoId'] ) { - $blockIds[] = $status['autoId']; // automatic block - } + $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] ); $log->addRelations( 'ipb_id', $blockIds, $log_id ); # Report to the user