Index: trunk/phase3/includes/Block.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry, |
20 | 20 | $mRangeStart, $mRangeEnd, $mAnonOnly, $mEnableAutoblock, $mHideName, |
21 | 21 | $mBlockEmail, $mByName, $mAngryAutoblock, $mAllowUsertalk; |
22 | | - private $mForUpdate, $mFromMaster; |
| 22 | + private $mFromMaster; |
23 | 23 | |
24 | 24 | const TYPE_USER = 1; |
25 | 25 | const TYPE_IP = 2; |
— | — | @@ -46,7 +46,6 @@ |
47 | 47 | $this->mHideName = $hideName; |
48 | 48 | $this->mBlockEmail = $blockEmail; |
49 | 49 | $this->mAllowUsertalk = $allowUsertalk; |
50 | | - $this->mForUpdate = false; |
51 | 50 | $this->mFromMaster = false; |
52 | 51 | $this->mByName = $byName; |
53 | 52 | $this->mAngryAutoblock = false; |
— | — | @@ -126,31 +125,6 @@ |
127 | 126 | } |
128 | 127 | |
129 | 128 | /** |
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 | | - /** |
155 | 129 | * Get a block from the DB, with either the given address or the given username |
156 | 130 | * |
157 | 131 | * @param $address string The IP address of the user, or blank to skip IP blocks |
— | — | @@ -162,8 +136,7 @@ |
163 | 137 | public function load( $address = '', $user = 0, $killExpired = true ) { |
164 | 138 | wfDebug( "Block::load: '$address', '$user', $killExpired\n" ); |
165 | 139 | |
166 | | - $options = array(); |
167 | | - $db = $this->getDBOptions( $options ); |
| 140 | + $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE ); |
168 | 141 | |
169 | 142 | if ( 0 == $user && $address === '' ) { |
170 | 143 | # Invalid user specification, not blocked |
— | — | @@ -175,7 +148,7 @@ |
176 | 149 | # Try user block |
177 | 150 | if ( $user ) { |
178 | 151 | $res = $db->resultObject( $db->select( 'ipblocks', '*', array( 'ipb_user' => $user ), |
179 | | - __METHOD__, $options ) ); |
| 152 | + __METHOD__ ) ); |
180 | 153 | |
181 | 154 | if ( $this->loadFromResult( $res, $killExpired ) ) { |
182 | 155 | return true; |
— | — | @@ -300,8 +273,7 @@ |
301 | 274 | # Blocks should not cross a /16 boundary. |
302 | 275 | $range = substr( $iaddr, 0, 4 ); |
303 | 276 | |
304 | | - $options = array(); |
305 | | - $db = $this->getDBOptions( $options ); |
| 277 | + $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE ); |
306 | 278 | $conds = array( |
307 | 279 | 'ipb_range_start' . $db->buildLike( $range, $db->anyString() ), |
308 | 280 | "ipb_range_start <= '$iaddr'", |
— | — | @@ -312,7 +284,7 @@ |
313 | 285 | $conds['ipb_anon_only'] = 0; |
314 | 286 | } |
315 | 287 | |
316 | | - $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) ); |
| 288 | + $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__ ) ); |
317 | 289 | $success = $this->loadFromResult( $res, $killExpired ); |
318 | 290 | |
319 | 291 | return $success; |
— | — | @@ -740,9 +712,10 @@ |
741 | 713 | |
742 | 714 | /** |
743 | 715 | * Get/set the SELECT ... FOR UPDATE flag |
| 716 | + * @deprecated since 1.18 |
744 | 717 | */ |
745 | 718 | public function forUpdate( $x = null ) { |
746 | | - return wfSetVar( $this->mForUpdate, $x ); |
| 719 | + # noop |
747 | 720 | } |
748 | 721 | |
749 | 722 | /** |