Index: trunk/extensions/InterfaceConcurrency/InterfaceConcurrency.hooks.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
17 | | - * Runs InterfaceConcurrency schema updates# |
| 17 | + * Runs InterfaceConcurrency schema updates |
18 | 18 | * |
19 | 19 | * @param $updater DatabaseUpdater |
20 | 20 | */ |
Index: trunk/extensions/InterfaceConcurrency/includes/ConcurrencyCheck.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | if ( $wgConcurrency['TrustMemc'] ) { |
66 | 66 | $cached = $wgMemc->get( $cacheKey ); |
67 | 67 | if ( $cached ) { |
68 | | - if ( ! $override && $cached['userId'] != $userId && $cached['expiration'] > time() ) { |
| 68 | + if ( !$override && $cached['userId'] != $userId && $cached['expiration'] > time() ) { |
69 | 69 | // this is already checked out. |
70 | 70 | return false; |
71 | 71 | } |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | |
75 | 75 | // attempt an insert, check success (this is atomic) |
76 | 76 | $insertError = null; |
77 | | - $res = $dbw->insert( |
| 77 | + $dbw->insert( |
78 | 78 | 'concurrencycheck', |
79 | 79 | array( |
80 | 80 | 'cc_resource_type' => $this->resourceType, |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | // if the insert failed, it's necessary to check the expiration. |
98 | 98 | // here, check by deleting, since that permits the use of write locks |
99 | 99 | // (SELECT..LOCK IN SHARE MODE), rather than read locks (SELECT..FOR UPDATE) |
100 | | - $dbw->begin(); |
| 100 | + $dbw->begin( __METHOD__ ); |
101 | 101 | $dbw->delete( |
102 | 102 | 'concurrencycheck', |
103 | 103 | array( |
— | — | @@ -125,8 +125,13 @@ |
126 | 126 | // this was a cache miss. populate the cache with data from the db. |
127 | 127 | // cache is set to expire at the same time as the checkout, since it'll become invalid then anyway. |
128 | 128 | // inside this transaction, a row-level lock is established which ensures cache concurrency |
129 | | - $wgMemc->set( $cacheKey, array( 'userId' => $row->cc_user, 'expiration' => wfTimestamp( TS_UNIX, $row->cc_expiration ) ), wfTimestamp( TS_UNIX, $row->cc_expiration ) - time() ); |
130 | | - $dbw->rollback(); |
| 129 | + $wgMemc->set( $cacheKey, array( |
| 130 | + 'userId' => $row->cc_user, |
| 131 | + 'expiration' => wfTimestamp( TS_UNIX, $row->cc_expiration ) |
| 132 | + ), |
| 133 | + wfTimestamp( TS_UNIX, $row->cc_expiration ) - time() |
| 134 | + ); |
| 135 | + $dbw->rollback( __METHOD__ ); |
131 | 136 | return false; |
132 | 137 | } |
133 | 138 | |
— | — | @@ -149,7 +154,7 @@ |
150 | 155 | // cache the result. |
151 | 156 | $wgMemc->set( $cacheKey, array( 'userId' => $userId, 'expiration' => $expiration ), $this->expirationTime ); |
152 | 157 | |
153 | | - $dbw->commit(); |
| 158 | + $dbw->commit( __METHOD__ ); |
154 | 159 | return true; |
155 | 160 | } |
156 | 161 | |
— | — | @@ -257,10 +262,10 @@ |
258 | 263 | // solution above could be implemented instead. |
259 | 264 | $queryParams = array(); |
260 | 265 | if ( $wgDBtype === 'mysql' ) { |
261 | | - $queryParamsp[] = 'LOCK IN SHARE MODE'; |
| 266 | + $queryParams[] = 'LOCK IN SHARE MODE'; |
262 | 267 | |
263 | 268 | // the transaction seems incongruous, I know, but it's to keep the cache update atomic. |
264 | | - $dbw->begin(); |
| 269 | + $dbw->begin( __METHOD__ ); |
265 | 270 | } |
266 | 271 | |
267 | 272 | $res = $dbw->select( |
— | — | @@ -293,7 +298,7 @@ |
294 | 299 | |
295 | 300 | if ( $wgDBtype === 'mysql' ) { |
296 | 301 | // end the transaction. |
297 | | - $dbw->rollback(); |
| 302 | + $dbw->rollback( __METHOD__ ); |
298 | 303 | } |
299 | 304 | } |
300 | 305 | |
Index: trunk/extensions/InterfaceConcurrency/ApiConcurrency.php |
— | — | @@ -93,6 +93,9 @@ |
94 | 94 | return __CLASS__ . ': $Id: ApiConcurrency.php 108560 2012-01-10 23:12:00Z reedy $'; |
95 | 95 | } |
96 | 96 | |
| 97 | + /** |
| 98 | + * @param $user User |
| 99 | + */ |
97 | 100 | private function checkPermission( $user ) { |
98 | 101 | if ( $user->isAnon() ) { |
99 | 102 | $this->dieUsage( "You don't have permission to do that", 'permission-denied' ); |