http://www.mediawiki.org/wiki/Special:Code/MediaWiki/84525
Revision: 84525
Author: aaron
Date: 2011-03-22 11:51:09 +0000 (Tue, 22 Mar 2011)
Log Message:
-----------
Fixed daft error in r84523 so "angry" autoblocks work again
Modified Paths:
--------------
trunk/phase3/includes/Block.php
trunk/phase3/includes/specials/SpecialBlock.php
Modified: trunk/phase3/includes/Block.php
===================================================================
--- trunk/phase3/includes/Block.php 2011-03-22 11:45:18 UTC (rev 84524)
+++ trunk/phase3/includes/Block.php 2011-03-22 11:51:09 UTC (rev 84525)
@@ -488,13 +488,14 @@
* 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 @@
$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 @@
* 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 @@
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 @@
} 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;
}
/**
Modified: trunk/phase3/includes/specials/SpecialBlock.php
===================================================================
--- trunk/phase3/includes/specials/SpecialBlock.php 2011-03-22 11:45:18 UTC
(rev 84524)
+++ trunk/phase3/includes/specials/SpecialBlock.php 2011-03-22 11:51:09 UTC
(rev 84525)
@@ -623,10 +623,7 @@
$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
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs