r65184 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65183‎ | r65184 | r65185 >
Date:20:59, 17 April 2010
Author:platonides
Status:resolved
Tags:
Comment:
Follow up r64982. Autoblocks aren't automatically set just by storing ipb_enable_autoblock, we need to look for them.
So do this properly and use Block class to insert the block.
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Block.php
@@ -377,9 +377,10 @@
378378 *
379379 * @return Boolean: whether or not the insertion was successful.
380380 */
381 - public function insert() {
 381+ public function insert($dbw = null) {
382382 wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" );
383 - $dbw = wfGetDB( DB_MASTER );
 383+ if ( $dbw === null)
 384+ $dbw = wfGetDB( DB_MASTER );
384385
385386 $this->validateBlockParams();
386387 $this->initialiseRange();
Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -1088,30 +1088,34 @@
10891089 $blockReason = wfMsgReal( 'centralauth-admin-suppressreason',
10901090 array( $by, $reason ), true, $lang );
10911091
1092 - $ipbID = $dbw->nextSequenceValue( 'ipblocks_ipb_id_seq' );
1093 - $dbw->insert( 'ipblocks',
1094 - array(
1095 - 'ipb_id' => $ipbID,
1096 - 'ipb_address' => $this->mName,
1097 - 'ipb_user' => $data['id'],
1098 - 'ipb_by' => 0,
1099 - 'ipb_by_text' => $by,
1100 - 'ipb_reason' => $blockReason,
1101 - 'ipb_timestamp' => $dbw->timestamp( wfTimestampNow() ),
1102 - 'ipb_auto' => false,
1103 - 'ipb_anon_only' => false,
1104 - 'ipb_create_account' => true,
1105 - 'ipb_enable_autoblock' => true,
1106 - 'ipb_expiry' => Block::infinity(),
1107 - 'ipb_range_start' => '',
1108 - 'ipb_range_end' => '',
1109 - 'ipb_deleted' => true,
1110 - 'ipb_block_email' => true,
1111 - 'ipb_allow_usertalk' => false
1112 - ), __METHOD__, array( 'IGNORE' )
1113 - );
1114 -
 1092+ $block = new Block(
 1093+ /* $address */ $this->mName,
 1094+ /* $user */ $data['id'],
 1095+ /* $by */ 0,
 1096+ //'ipb_by_text' => $by,
 1097+ /* $reason */ $blockReason,
 1098+ /* $timestamp */ wfTimestampNow(),
 1099+ /* $auto */ false,
 1100+ /* $expiry */ Block::infinity(),
 1101+ /* anonOnly */ false,
 1102+ /* $createAccount */ true,
 1103+ /* $enableAutoblock */ true,
 1104+ /* $hideName (ipb_deleted) */ true,
 1105+ /* $blockEmail */ true,
 1106+ /* $allowUsertalk */ false
 1107+ );
 1108+
 1109+ # On normal block, BlockIp hook would be run here, but doing
 1110+ # that from CentralAuth doesn't seem a good idea...
 1111+
 1112+ if ( !$block->insert( $dbw ) ) {
 1113+ return array( 'ipb_already_blocked' );
 1114+ }
 1115+ # Ditto for BlockIpComplete hook.
 1116+
11151117 IPBlockForm::suppressUserName( $this->mName, $data['id'], $dbw );
 1118+
 1119+ # Locally log to suppress ?
11161120 } else {
11171121 $dbw->delete(
11181122 'ipblocks',

Follow-up revisions

RevisionCommit summaryAuthorDate
r65185Add yet another parameter for Block construction, so this doesn't show runJob...platonides21:06, 17 April 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r64982(Bug 23114) CentralAuth global suppression should use autoblock.platonides21:12, 12 April 2010

Status & tagging log