Fix for r79874: only set $mRevIdFetched from fetchContent(), it was overriden by...
[lhc/web/wiklou.git] / includes / installer / MysqlUpdater.php
index 4550e05..5cfd628 100644 (file)
@@ -8,12 +8,12 @@
 
 /**
  * Mysql update list and mysql-specific update functions.
- * 
+ *
  * @ingroup Deployment
  * @since 1.17
  */
 class MysqlUpdater extends DatabaseUpdater {
-       
+
        protected function getCoreUpdateList() {
                return array(
                        // 1.2
@@ -171,6 +171,8 @@ class MysqlUpdater extends DatabaseUpdater {
                        array( 'doCollationUpdate' ),
                        array( 'addTable', 'msg_resource',                      'patch-msg_resource.sql' ),
                        array( 'addTable', 'module_deps',                       'patch-module_deps.sql' ),
+                       array( 'dropIndex', 'archive', 'ar_page_revid',         'patch-archive_kill_ar_page_revid.sql' ),
+                       array( 'addIndex', 'archive', 'ar_revid',               'patch-archive_ar_revid.sql' ),
                );
        }
 
@@ -191,7 +193,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        $this->output( "...$table table has correct $field encoding.\n" );
                } else {
                        $this->output( "Fixing $field encoding on $table table... " );
-                       $this->db->applyPatch( $patchFile );
+                       $this->applyPatch( $patchFile );
                        $this->output( "ok\n" );
                }
        }
@@ -253,7 +255,7 @@ class MysqlUpdater extends DatabaseUpdater {
        }
 
        protected function doOldLinksUpdate() {
-               $cl = new ConvertLinks();
+               $cl = $this->maintenance->runChild( 'ConvertLinks' );
                $cl->execute();
        }
 
@@ -311,6 +313,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        $this->output( wfTimestamp( TS_DB ) );
                        $this->output( "......<b>Found duplicate entries</b>\n" );
                        $this->output( sprintf( "<b>      %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
+                       $duplicate = array();
                        foreach ( $rows as $row ) {
                                if ( ! isset( $duplicate[$row->cur_namespace] ) ) {
                                        $duplicate[$row->cur_namespace] = array();
@@ -355,7 +358,7 @@ class MysqlUpdater extends DatabaseUpdater {
                                $prev_namespace = $row->cur_namespace;
                        }
                        $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')';
-                       $rows = $this->db->query( $sql, __METHOD__ );
+                       $this->db->query( $sql, __METHOD__ );
                        $this->output( wfTimestamp( TS_DB ) );
                        $this->output( "......<b>Deleted</b> " . $this->db->affectedRows() . " records.\n" );
                }
@@ -507,10 +510,10 @@ class MysqlUpdater extends DatabaseUpdater {
                        $likeprefix = str_replace( '_', '\\_', $prefix );
 
                        $sql = "UPDATE $pagelinks
-                                  SET pl_namespace=$ns,
-                                      pl_title=TRIM(LEADING '$prefix:' FROM pl_title)
-                                WHERE pl_namespace=0
-                                  AND pl_title LIKE '$likeprefix:%'";
+                                          SET pl_namespace=$ns,
+                                                  pl_title=TRIM(LEADING '$prefix:' FROM pl_title)
+                                        WHERE pl_namespace=0
+                                          AND pl_title LIKE '$likeprefix:%'";
 
                        $this->db->query( $sql, __METHOD__ );
                        $this->output( "ok\n" );
@@ -518,7 +521,7 @@ class MysqlUpdater extends DatabaseUpdater {
        }
 
        protected function doUserUniqueUpdate() {
-               $duper = new UserDupes( $this->db );
+               $duper = new UserDupes( $this->db, array( $this, 'output' ) );
                if ( $duper->hasUniqueIndex() ) {
                        $this->output( "...already have unique user_name index.\n" );
                        return;
@@ -601,7 +604,7 @@ class MysqlUpdater extends DatabaseUpdater {
         */
        protected function doWatchlistNull() {
                $info = $this->db->fieldInfo( 'watchlist', 'wl_notificationtimestamp' );
-               if ( $info->nullable() ) {
+               if ( $info->isNullable() ) {
                        $this->output( "...wl_notificationtimestamp is already nullable.\n" );
                        return;
                }
@@ -617,13 +620,15 @@ class MysqlUpdater extends DatabaseUpdater {
         * @see bug 3946
         */
        protected function doPageRandomUpdate() {
-               $this->output( "Setting page_random to a random value on rows where it equals 0..." );
-
                $page = $this->db->tableName( 'page' );
                $this->db->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", __METHOD__ );
                $rows = $this->db->affectedRows();
 
-               $this->output( "changed $rows rows\n" );
+               if( $rows ) {
+                       $this->output( "Set page_random to a random value on $rows rows where it was set to 0\n" );
+               } else {
+                       $this->output( "...no page_random rows needed to be set\n" );
+               }
        }
 
        protected function doTemplatelinksUpdate() {
@@ -689,14 +694,14 @@ class MysqlUpdater extends DatabaseUpdater {
                        $this->output( "...page_restrictions table already exists.\n" );
                        return;
                }
-       
+
                $this->output( "Creating page_restrictions table..." );
                $this->applyPatch( 'patch-page_restrictions.sql' );
                $this->applyPatch( 'patch-page_restrictions_sortkey.sql' );
                $this->output( "ok\n" );
 
                $this->output( "Migrating old restrictions to new table...\n" );
-               $task = new UpdateRestrictions();
+               $task = $this->maintenance->runChild( 'UpdateRestrictions' );
                $task->execute();
        }
 
@@ -719,7 +724,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        "may want to hit Ctrl-C and do this manually with maintenance/\n" .
                        "populateCategory.php.\n"
                );
-               $task = new PopulateCategory();
+               $task = $this->maintenance->runChild( 'PopulateCategory' );
                $task->execute();
                $this->output( "Done populating category table.\n" );
        }
@@ -730,7 +735,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $task = new PopulateParentId();
+               $task = $this->maintenance->runChild( 'PopulateParentId' );
                $task->execute();
        }
 
@@ -794,7 +799,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $task = new PopulateRevisionLength();
+               $task = $this->maintenance->runChild( 'PopulateRevisionLength' );
                $task->execute();
        }