* Abstracted table locks in maintenance/updateSearchIndex.php
authorMax Semenik <maxsem@users.mediawiki.org>
Sun, 25 Oct 2009 09:42:00 +0000 (09:42 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Sun, 25 Oct 2009 09:42:00 +0000 (09:42 +0000)
* Fixed MySQL's table locking, stabstabstab PHP

includes/db/DatabaseMysql.php
maintenance/updateSearchIndex.php

index 4042546..48b21a2 100644 (file)
@@ -348,7 +348,7 @@ class DatabaseMysql extends DatabaseBase {
 
                foreach( $write as $table ) {
                        $tbl = $this->tableName( $table ) . 
-                                       $lowPriority ? ' LOW_PRIORITY' : '' . 
+                                       ( $lowPriority ? ' LOW_PRIORITY' : '' ) . 
                                        ' WRITE';
                        $items[] = $tbl;
                }
index 0adfd15..6bb290f 100644 (file)
@@ -147,16 +147,7 @@ class UpdateSearchIndex extends Maintenance {
        private function lockSearchindex( &$db ) {
                $write = array( 'searchindex' );
                $read = array( 'page', 'revision', 'text', 'interwiki' );
-               $items = array();
-       
-               foreach( $write as $table ) {
-                       $items[] = $db->tableName( $table ) . ' LOW_PRIORITY WRITE';
-               }
-               foreach( $read as $table ) {
-                       $items[] = $db->tableName( $table ) . ' READ';
-               }
-               $sql = "LOCK TABLES " . implode( ',', $items );
-               $db->query( $sql, 'updateSearchIndex.php ' . __METHOD__ );
+               $db->lockTables( $read, $write, 'updateSearchIndex.php ' . __METHOD__ );
        }
 
        /**
@@ -164,7 +155,7 @@ class UpdateSearchIndex extends Maintenance {
         * @param &$db Database object
         */
        private function unlockSearchindex( &$db ) {
-               $db->query( "UNLOCK TABLES", 'updateSearchIndex.php ' . __METHOD__ );
+               $db->unlockTables( 'updateSearchIndex.php ' . __METHOD__ );
        }
        
        /**