r109443 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109442‎ | r109443 | r109444 >
Date:22:18, 18 January 2012
Author:reedy
Status:ok
Tags:
Comment:
Fix $queryParamsp typo

Add __METHOD to begin/commit/rollback calls

Wrap a long line
Modified paths:
  • /trunk/extensions/InterfaceConcurrency/ApiConcurrency.php (modified) (history)
  • /trunk/extensions/InterfaceConcurrency/InterfaceConcurrency.hooks.php (modified) (history)
  • /trunk/extensions/InterfaceConcurrency/includes/ConcurrencyCheck.php (modified) (history)

Diff [purge]

Index: trunk/extensions/InterfaceConcurrency/InterfaceConcurrency.hooks.php
@@ -13,7 +13,7 @@
1414 }
1515
1616 /**
17 - * Runs InterfaceConcurrency schema updates#
 17+ * Runs InterfaceConcurrency schema updates
1818 *
1919 * @param $updater DatabaseUpdater
2020 */
Index: trunk/extensions/InterfaceConcurrency/includes/ConcurrencyCheck.php
@@ -64,7 +64,7 @@
6565 if ( $wgConcurrency['TrustMemc'] ) {
6666 $cached = $wgMemc->get( $cacheKey );
6767 if ( $cached ) {
68 - if ( ! $override && $cached['userId'] != $userId && $cached['expiration'] > time() ) {
 68+ if ( !$override && $cached['userId'] != $userId && $cached['expiration'] > time() ) {
6969 // this is already checked out.
7070 return false;
7171 }
@@ -73,7 +73,7 @@
7474
7575 // attempt an insert, check success (this is atomic)
7676 $insertError = null;
77 - $res = $dbw->insert(
 77+ $dbw->insert(
7878 'concurrencycheck',
7979 array(
8080 'cc_resource_type' => $this->resourceType,
@@ -96,7 +96,7 @@
9797 // if the insert failed, it's necessary to check the expiration.
9898 // here, check by deleting, since that permits the use of write locks
9999 // (SELECT..LOCK IN SHARE MODE), rather than read locks (SELECT..FOR UPDATE)
100 - $dbw->begin();
 100+ $dbw->begin( __METHOD__ );
101101 $dbw->delete(
102102 'concurrencycheck',
103103 array(
@@ -125,8 +125,13 @@
126126 // this was a cache miss. populate the cache with data from the db.
127127 // cache is set to expire at the same time as the checkout, since it'll become invalid then anyway.
128128 // 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__ );
131136 return false;
132137 }
133138
@@ -149,7 +154,7 @@
150155 // cache the result.
151156 $wgMemc->set( $cacheKey, array( 'userId' => $userId, 'expiration' => $expiration ), $this->expirationTime );
152157
153 - $dbw->commit();
 158+ $dbw->commit( __METHOD__ );
154159 return true;
155160 }
156161
@@ -257,10 +262,10 @@
258263 // solution above could be implemented instead.
259264 $queryParams = array();
260265 if ( $wgDBtype === 'mysql' ) {
261 - $queryParamsp[] = 'LOCK IN SHARE MODE';
 266+ $queryParams[] = 'LOCK IN SHARE MODE';
262267
263268 // the transaction seems incongruous, I know, but it's to keep the cache update atomic.
264 - $dbw->begin();
 269+ $dbw->begin( __METHOD__ );
265270 }
266271
267272 $res = $dbw->select(
@@ -293,7 +298,7 @@
294299
295300 if ( $wgDBtype === 'mysql' ) {
296301 // end the transaction.
297 - $dbw->rollback();
 302+ $dbw->rollback( __METHOD__ );
298303 }
299304 }
300305
Index: trunk/extensions/InterfaceConcurrency/ApiConcurrency.php
@@ -93,6 +93,9 @@
9494 return __CLASS__ . ': $Id: ApiConcurrency.php 108560 2012-01-10 23:12:00Z reedy $';
9595 }
9696
 97+ /**
 98+ * @param $user User
 99+ */
97100 private function checkPermission( $user ) {
98101 if ( $user->isAnon() ) {
99102 $this->dieUsage( "You don't have permission to do that", 'permission-denied' );

Sign-offs

UserFlagDate
Nikerabbitinspected09:15, 19 January 2012

Status & tagging log