r84336 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84335‎ | r84336 | r84337 >
Date:17:32, 19 March 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Block::forUpdate() is never called, and doesn't really make much sense in this context anyway; remove it and simplify.
Modified paths:
  • /trunk/phase3/includes/Block.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Block.php
@@ -18,7 +18,7 @@
1919 /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry,
2020 $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName,
2121 $mBlockEmail, $mByName, $mAngryAutoblock, $mAllowUsertalk;
22 - private $mForUpdate, $mFromMaster;
 22+ private $mFromMaster;
2323
2424 const TYPE_USER = 1;
2525 const TYPE_IP = 2;
@@ -46,7 +46,6 @@
4747 $this->mHideName = $hideName;
4848 $this->mBlockEmail = $blockEmail;
4949 $this->mAllowUsertalk = $allowUsertalk;
50 - $this->mForUpdate = false;
5150 $this->mFromMaster = false;
5251 $this->mByName = $byName;
5352 $this->mAngryAutoblock = false;
@@ -126,31 +125,6 @@
127126 }
128127
129128 /**
130 - * Get the DB object and set the reference parameter to the select options.
131 - * The options array will contain FOR UPDATE if appropriate.
132 - *
133 - * @param $options Array
134 - * @return Database
135 - */
136 - protected function &getDBOptions( &$options ) {
137 - global $wgAntiLockFlags;
138 -
139 - if ( $this->mForUpdate || $this->mFromMaster ) {
140 - $db = wfGetDB( DB_MASTER );
141 - if ( !$this->mForUpdate || ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) ) {
142 - $options = array();
143 - } else {
144 - $options = array( 'FOR UPDATE' );
145 - }
146 - } else {
147 - $db = wfGetDB( DB_SLAVE );
148 - $options = array();
149 - }
150 -
151 - return $db;
152 - }
153 -
154 - /**
155129 * Get a block from the DB, with either the given address or the given username
156130 *
157131 * @param $address string The IP address of the user, or blank to skip IP blocks
@@ -162,8 +136,7 @@
163137 public function load( $address = '', $user = 0, $killExpired = true ) {
164138 wfDebug( "Block::load: '$address', '$user', $killExpired\n" );
165139
166 - $options = array();
167 - $db = $this->getDBOptions( $options );
 140+ $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE );
168141
169142 if ( 0 == $user && $address === '' ) {
170143 # Invalid user specification, not blocked
@@ -175,7 +148,7 @@
176149 # Try user block
177150 if ( $user ) {
178151 $res = $db->resultObject( $db->select( 'ipblocks', '*', array( 'ipb_user' => $user ),
179 - __METHOD__, $options ) );
 152+ __METHOD__ ) );
180153
181154 if ( $this->loadFromResult( $res, $killExpired ) ) {
182155 return true;
@@ -300,8 +273,7 @@
301274 # Blocks should not cross a /16 boundary.
302275 $range = substr( $iaddr, 0, 4 );
303276
304 - $options = array();
305 - $db = $this->getDBOptions( $options );
 277+ $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE );
306278 $conds = array(
307279 'ipb_range_start' . $db->buildLike( $range, $db->anyString() ),
308280 "ipb_range_start <= '$iaddr'",
@@ -312,7 +284,7 @@
313285 $conds['ipb_anon_only'] = 0;
314286 }
315287
316 - $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) );
 288+ $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__ ) );
317289 $success = $this->loadFromResult( $res, $killExpired );
318290
319291 return $success;
@@ -740,9 +712,10 @@
741713
742714 /**
743715 * Get/set the SELECT ... FOR UPDATE flag
 716+ * @deprecated since 1.18
744717 */
745718 public function forUpdate( $x = null ) {
746 - return wfSetVar( $this->mForUpdate, $x );
 719+ # noop
747720 }
748721
749722 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r84337Follow-up r84336: break some long lineshappy-melon17:36, 19 March 2011

Status & tagging log