Index: trunk/phase3/includes/FileStore.php |
— | — | @@ -35,39 +35,22 @@ |
36 | 36 | * This is attached to your master database connection, so if you |
37 | 37 | * suffer an uncaught error the lock will be released when the |
38 | 38 | * connection is closed. |
39 | | - * |
40 | | - * @todo Probably only works on MySQL. Abstract to the Database class? |
| 39 | + * @see Database::lock() |
41 | 40 | */ |
42 | 41 | static function lock() { |
43 | | - global $wgDBtype; |
44 | | - if ($wgDBtype != 'mysql') |
45 | | - return true; |
46 | 42 | $dbw = wfGetDB( DB_MASTER ); |
47 | 43 | $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__ ); |
58 | 45 | } |
59 | 46 | |
60 | 47 | /** |
61 | 48 | * Release the global file store lock. |
| 49 | + * @see Database::unlock() |
62 | 50 | */ |
63 | 51 | static function unlock() { |
64 | | - global $wgDBtype; |
65 | | - if ($wgDBtype != 'mysql') |
66 | | - return true; |
67 | 52 | $dbw = wfGetDB( DB_MASTER ); |
68 | 53 | $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__ ); |
72 | 55 | } |
73 | 56 | |
74 | 57 | private static function lockName() { |