r44178 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44177‎ | r44178 | r44179 >
Date:16:29, 3 December 2008
Author:demon
Status:ok
Tags:
Comment:
This has been moved to Database already, use that instead.
Modified paths:
  • /trunk/phase3/includes/FileStore.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/FileStore.php
@@ -35,39 +35,22 @@
3636 * This is attached to your master database connection, so if you
3737 * suffer an uncaught error the lock will be released when the
3838 * connection is closed.
39 - *
40 - * @todo Probably only works on MySQL. Abstract to the Database class?
 39+ * @see Database::lock()
4140 */
4241 static function lock() {
43 - global $wgDBtype;
44 - if ($wgDBtype != 'mysql')
45 - return true;
4642 $dbw = wfGetDB( DB_MASTER );
4743 $lockname = $dbw->addQuotes( FileStore::lockName() );
48 - $result = $dbw->query( "SELECT GET_LOCK($lockname, 5) AS lockstatus", __METHOD__ );
49 - $row = $dbw->fetchObject( $result );
50 - $dbw->freeResult( $result );
51 -
52 - if( $row->lockstatus == 1 ) {
53 - return true;
54 - } else {
55 - wfDebug( __METHOD__." failed to acquire lock\n" );
56 - return false;
57 - }
 44+ return $dbw->lock( $lockname, __METHOD__ );
5845 }
5946
6047 /**
6148 * Release the global file store lock.
 49+ * @see Database::unlock()
6250 */
6351 static function unlock() {
64 - global $wgDBtype;
65 - if ($wgDBtype != 'mysql')
66 - return true;
6752 $dbw = wfGetDB( DB_MASTER );
6853 $lockname = $dbw->addQuotes( FileStore::lockName() );
69 - $result = $dbw->query( "SELECT RELEASE_LOCK($lockname)", __METHOD__ );
70 - $dbw->fetchObject( $result );
71 - $dbw->freeResult( $result );
 54+ return $dbw->unlock( $lockname, __METHOD__ );
7255 }
7356
7457 private static function lockName() {

Status & tagging log