Drop unused database field ss_admins
[lhc/web/wiklou.git] / includes / installer / MysqlUpdater.php
index 1c2c111..037af7b 100644 (file)
@@ -2,6 +2,21 @@
 /**
  * MySQL-specific updater.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup Deployment
  */
@@ -182,17 +197,26 @@ class MysqlUpdater extends DatabaseUpdater {
                        array( 'addTable', 'user_former_groups',                'patch-user_former_groups.sql'),
 
                        // 1.19
-                       array( 'addTable', 'config',                            'patch-config.sql' ),
                        array( 'addIndex', 'logging',       'type_action',      'patch-logging-type-action-index.sql'),
                        array( 'doMigrateUserOptions' ),
                        array( 'dropField', 'user',         'user_options', 'patch-drop-user_options.sql' ),
                        array( 'addField', 'revision',      'rev_sha1',         'patch-rev_sha1.sql' ),
                        array( 'addField', 'archive',       'ar_sha1',          'patch-ar_sha1.sql' ),
                        array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
-                       array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ),
+                       array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase.sql' ),
                        array( 'addField',      'uploadstash',  'us_chunk_inx',         'patch-uploadstash_chunk.sql' ),
                        array( 'addfield', 'job',           'job_timestamp',    'patch-jobs-add-timestamp.sql' ),
-                       array( 'addTable', 'concurrencycheck',                                  'patch-concurrencycheck.sql'),
+                       array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase.sql' ),
+
+                       // 1.20
+                       array( 'addTable', 'config',                            'patch-config.sql' ),
+                       array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ),
+                       array( 'addField', 'ipblocks',      'ipb_parent_block_id',           'patch-ipb-parent-block-id.sql' ),
+                       array( 'addIndex', 'ipblocks',      'ipb_parent_block_id',           'patch-ipb-parent-block-id-index.sql' ),
+                       array( 'dropField', 'category',     'cat_hidden',       'patch-cat_hidden.sql' ),
+
+                       // 1.21
+                       array( 'dropField', 'site_stats',   'ss_admins',        'patch-drop-ss_admins.sql' ),
                );
        }
 
@@ -212,9 +236,7 @@ class MysqlUpdater extends DatabaseUpdater {
                if ( in_array( 'binary', $flags ) ) {
                        $this->output( "...$table table has correct $field encoding.\n" );
                } else {
-                       $this->output( "Fixing $field encoding on $table table... " );
-                       $this->applyPatch( $patchFile );
-                       $this->output( "done.\n" );
+                       $this->applyPatch( $patchFile, false, "Fixing $field encoding on $table table" );
                }
        }
 
@@ -251,12 +273,8 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( 'Creating interwiki table...' );
-               $this->applyPatch( 'patch-interwiki.sql' );
-               $this->output( "done.\n" );
-               $this->output( 'Adding default interwiki definitions...' );
-               $this->applyPatch( "$IP/maintenance/interwiki.sql", true );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-interwiki.sql', false, 'Creating interwiki table' );
+               $this->applyPatch( "$IP/maintenance/interwiki.sql", true, 'Adding default interwiki definitions' );
        }
 
        /**
@@ -272,9 +290,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Updating indexes to 20031107..." );
-               $this->applyPatch( 'patch-indexes.sql', true );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-indexes.sql', true, "Updating indexes to 20031107" );
        }
 
        protected function doOldLinksUpdate() {
@@ -289,10 +305,9 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Fixing ancient broken imagelinks table.\n" );
-               $this->output( "NOTE: you will have to run maintenance/refreshLinks.php after this.\n" );
-               $this->applyPatch( 'patch-fix-il_from.sql' );
-               $this->output( "done.\n" );
+               if( $this->applyPatch( 'patch-fix-il_from.sql', false, "Fixing ancient broken imagelinks table." ) ) {
+                       $this->output("NOTE: you will have to run maintenance/refreshLinks.php after this." );
+               }
        }
 
        /**
@@ -514,9 +529,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Converting links and brokenlinks tables to pagelinks... " );
-               $this->applyPatch( 'patch-pagelinks.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-pagelinks.sql', false, "Converting links and brokenlinks tables to pagelinks" );
 
                global $wgContLang;
                foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
@@ -552,9 +565,7 @@ class MysqlUpdater extends DatabaseUpdater {
                if ( !$duper->clearDupes() ) {
                        $this->output( "WARNING: This next step will probably fail due to unfixed duplicates...\n" );
                }
-               $this->output( "Adding unique index on user_name... " );
-               $this->applyPatch( 'patch-user_nameindex.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-user_nameindex.sql', false, "Adding unique index on user_name" );
        }
 
        protected function doUserGroupsUpdate() {
@@ -567,9 +578,7 @@ class MysqlUpdater extends DatabaseUpdater {
                                $this->db->query( "ALTER TABLE $oldug RENAME TO $newug", __METHOD__ );
                                $this->output( "done.\n" );
 
-                               $this->output( "Re-adding fresh user_groups table... " );
-                               $this->applyPatch( 'patch-user_groups.sql' );
-                               $this->output( "done.\n" );
+                               $this->applyPatch( 'patch-user_groups.sql', false, "Re-adding fresh user_groups table" );
 
                                $this->output( "***\n" );
                                $this->output( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" );
@@ -581,15 +590,11 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Adding user_groups table... " );
-               $this->applyPatch( 'patch-user_groups.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-user_groups.sql', false, "Adding user_groups table" );
 
                if ( !$this->db->tableExists( 'user_rights', __METHOD__ ) ) {
                        if ( $this->db->fieldExists( 'user', 'user_rights', __METHOD__ ) ) {
-                               $this->output( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." );
-                               $this->db->applyPatch( 'patch-user_rights.sql' );
-                               $this->output( "done.\n" );
+                               $this->db->applyPatch( 'patch-user_rights.sql', false, "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion" );
                        } else {
                                $this->output( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" );
                                $this->output( "*** You may need to manually configure some sysops by manipulating\n" );
@@ -631,9 +636,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Making wl_notificationtimestamp nullable... " );
-               $this->applyPatch( 'patch-watchlist-null.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-watchlist-null.sql', false, "Making wl_notificationtimestamp nullable" );
        }
 
        /**
@@ -659,8 +662,8 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Creating templatelinks table...\n" );
-               $this->applyPatch( 'patch-templatelinks.sql' );
+               $this->applyPatch( 'patch-templatelinks.sql', false, "Creating templatelinks table" );
+
                $this->output( "Populating...\n" );
                if ( wfGetLB()->getServerCount() > 1 ) {
                        // Slow, replication-friendly update
@@ -701,8 +704,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        !$this->indexHasField( 'templatelinks', 'tl_namespace', 'tl_from' ) ||
                        !$this->indexHasField( 'imagelinks', 'il_to', 'il_from' ) )
                {
-                       $this->applyPatch( 'patch-backlinkindexes.sql' );
-                       $this->output( "...backlinking indices updated\n" );
+                       $this->applyPatch( 'patch-backlinkindexes.sql', false, "Updating backlinking indices" );
                }
        }
 
@@ -717,9 +719,8 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Creating page_restrictions table..." );
-               $this->applyPatch( 'patch-page_restrictions.sql' );
-               $this->applyPatch( 'patch-page_restrictions_sortkey.sql' );
+               $this->applyPatch( 'patch-page_restrictions.sql', false, "Creating page_restrictions table (1/2)" );
+               $this->applyPatch( 'patch-page_restrictions_sortkey.sql', false, "Creating page_restrictions table (2/2)" );
                $this->output( "done.\n" );
 
                $this->output( "Migrating old restrictions to new table...\n" );
@@ -729,8 +730,7 @@ class MysqlUpdater extends DatabaseUpdater {
 
        protected function doCategorylinksIndicesUpdate() {
                if ( !$this->indexHasField( 'categorylinks', 'cl_sortkey', 'cl_from' ) ) {
-                       $this->applyPatch( 'patch-categorylinksindex.sql' );
-                       $this->output( "...categorylinks indices updated\n" );
+                       $this->applyPatch( 'patch-categorylinksindex.sql', false, "Updating categorylinks Indices" );
                }
        }
 
@@ -769,18 +769,14 @@ class MysqlUpdater extends DatabaseUpdater {
                } elseif ( $this->db->fieldExists( 'profiling', 'pf_memory', __METHOD__ ) ) {
                        $this->output( "...profiling table has pf_memory field.\n" );
                } else {
-                       $this->output( "Adding pf_memory field to table profiling..." );
-                       $this->applyPatch( 'patch-profiling-memory.sql' );
-                       $this->output( "done.\n" );
+                       $this->applyPatch( 'patch-profiling-memory.sql', false, "Adding pf_memory field to table profiling" );
                }
        }
 
        protected function doFilearchiveIndicesUpdate() {
                $info = $this->db->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ );
                if ( !$info ) {
-                       $this->output( "Updating filearchive indices..." );
-                       $this->applyPatch( 'patch-filearchive-user-index.sql' );
-                       $this->output( "done.\n" );
+                       $this->applyPatch( 'patch-filearchive-user-index.sql', false, "Updating filearchive indices" );
                }
        }
 
@@ -791,9 +787,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Making pl_namespace, tl_namespace and il_to indices UNIQUE... " );
-               $this->applyPatch( 'patch-pl-tl-il-unique.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-pl-tl-il-unique.sql', false, "Making pl_namespace, tl_namespace and il_to indices UNIQUE" );
        }
 
        protected function renameEuWikiId() {
@@ -802,9 +796,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Renaming eu_wiki_id -> eu_local_id... " );
-               $this->applyPatch( 'patch-eu_local_id.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-eu_local_id.sql', false, "Renaming eu_wiki_id -> eu_local_id" );
        }
 
        protected function doUpdateMimeMinorField() {
@@ -813,9 +805,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Altering all *_mime_minor fields to 100 bytes in size ... " );
-               $this->applyPatch( 'patch-mime_minor_length.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-mime_minor_length.sql', false, "Altering all *_mime_minor fields to 100 bytes in size" );
        }
 
        protected function doClFieldsUpdate() {
@@ -824,9 +814,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( 'Updating categorylinks (again)...' );
-               $this->applyPatch( 'patch-categorylinks-better-collation2.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-categorylinks-better-collation2.sql', false, 'Updating categorylinks (again)' );
        }
 
        protected function doLangLinksLengthUpdate() {
@@ -835,9 +823,7 @@ class MysqlUpdater extends DatabaseUpdater {
                $row = $this->db->fetchObject( $res );
 
                if ( $row && $row->Type == "varbinary(10)" ) {
-                       $this->output( 'Updating length of ll_lang in langlinks...' );
-                       $this->applyPatch( 'patch-langlinks-ll_lang-20.sql' );
-                       $this->output( "done.\n" );
+                       $this->applyPatch( 'patch-langlinks-ll_lang-20.sql', false, 'Updating length of ll_lang in langlinks' );
                } else {
                        $this->output( "...ll_lang is up-to-date.\n" );
                }
@@ -850,8 +836,6 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               $this->output( "Making user_last_timestamp nullable... " );
-               $this->applyPatch( 'patch-user-newtalk-timestamp-null.sql' );
-               $this->output( "done.\n" );
+               $this->applyPatch( 'patch-user-newtalk-timestamp-null.sql', false, "Making user_last_timestamp nullable" );
        }
 }