In LogFormatter:
[lhc/web/wiklou.git] / includes / installer / DatabaseUpdater.php
index 9657483..f2e36ae 100644 (file)
@@ -153,6 +153,8 @@ abstract class DatabaseUpdater {
         * Add a new update coming from an extension. This should be called by
         * extensions while executing the LoadExtensionSchemaUpdates hook.
         *
+        * @since 1.17
+        *
         * @param $update Array: the update to run. Format is the following:
         *                first item is the callback function, it also can be a
         *                simple string with the name of a function in this class,
@@ -167,6 +169,9 @@ abstract class DatabaseUpdater {
        /**
         * Convenience wrapper for addExtensionUpdate() when adding a new table (which
         * is the most common usage of updaters in an extension)
+        *
+        * @since 1.18
+        *
         * @param $tableName String Name of table to create
         * @param $sqlPath String Full path to the schema file
         */
@@ -175,6 +180,8 @@ abstract class DatabaseUpdater {
        }
 
        /**
+        * @since 1.19
+        *
         * @param $tableName string
         * @param $indexName string
         * @param $sqlPath string
@@ -184,6 +191,9 @@ abstract class DatabaseUpdater {
        }
 
        /**
+        *
+        * @since 1.19
+        *
         * @param $tableName string
         * @param $columnName string
         * @param $sqlPath string
@@ -193,7 +203,10 @@ abstract class DatabaseUpdater {
        }
 
        /**
-        * Add a maintenance script to be run after the database updates are complete
+        * Add a maintenance script to be run after the database updates are complete.
+        * 
+        * @since 1.19
+        * 
         * @param $class string Name of a Maintenance subclass
         */
        public function addPostDatabaseUpdateMaintenance( $class ) {
@@ -210,6 +223,8 @@ abstract class DatabaseUpdater {
        }
 
        /**
+        * @since 1.17
+        * 
         * @return array
         */
        public function getPostDatabaseUpdateMaintenance() {
@@ -235,6 +250,10 @@ abstract class DatabaseUpdater {
 
                $this->setAppliedUpdates( $wgVersion, $this->updates );
 
+               if ( isset( $what['stats'] ) ) {
+                       $this->checkStats();
+               }
+
                if ( isset( $what['purge'] ) ) {
                        $this->purgeCache();
 
@@ -242,9 +261,6 @@ abstract class DatabaseUpdater {
                                $this->rebuildLocalisationCache();
                        }
                }
-               if ( isset( $what['stats'] ) ) {
-                       $this->checkStats();
-               }
        }
 
        /**
@@ -412,10 +428,10 @@ abstract class DatabaseUpdater {
         * @param $fullpath Boolean Whether to treat $patch path as a relative or not
         */
        protected function addTable( $name, $patch, $fullpath = false ) {
-               $this->output( "Creating $name table... " );
                if ( $this->db->tableExists( $name, __METHOD__ ) ) {
-                       $this->output( "...$name table already exists. Skipping create table $name\n" );
+                       $this->output( "...$name table already exists.\n" );
                } else {
+                       $this->output( "Creating $name table..." );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "done.\n" );
                }
@@ -429,12 +445,12 @@ abstract class DatabaseUpdater {
         * @param $fullpath Boolean Whether to treat $patch path as a relative or not
         */
        protected function addField( $table, $field, $patch, $fullpath = false ) {
-               $this->output( "Adding $field field to table $table..." );
                if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
                        $this->output( "...$table table does not exist, skipping new field patch.\n" );
                } elseif ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
-                       $this->output( "...already have $field field in $table table, skipping new field patch.\n" );
+                       $this->output( "...have $field field in $table table.\n" );
                } else {
+                       $this->output( "Adding $field field to table $table..." );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "done.\n" );
                }
@@ -448,10 +464,10 @@ abstract class DatabaseUpdater {
         * @param $fullpath Boolean Whether to treat $patch path as a relative or not
         */
        protected function addIndex( $table, $index, $patch, $fullpath = false ) {
-               $this->output( "Adding $index key to table $table..." );
                if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
-                       $this->output( "...$index key already set on $table table, skipping new index patch.\n" );
+                       $this->output( "...index $index already set on $table table.\n" );
                } else {
+                       $this->output( "Adding index $index to table $table... " );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "done.\n" );
                }
@@ -466,12 +482,12 @@ abstract class DatabaseUpdater {
         * @param $fullpath Boolean Whether to treat $patch path as a relative or not
         */
        protected function dropField( $table, $field, $patch, $fullpath = false ) {
-               $this->output( "Dropping field $field from table $table..." );
                if ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) {
+                       $this->output( "Table $table contains $field field. Dropping... " );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "done.\n" );
                } else {
-                       $this->output( "...$table table does not contain $field field, skipping drop field.\n" );
+                       $this->output( "...$table table does not contain $field field.\n" );
                }
        }
 
@@ -484,12 +500,12 @@ abstract class DatabaseUpdater {
         * @param $fullpath Boolean: Whether to treat $patch path as a relative or not
         */
        protected function dropIndex( $table, $index, $patch, $fullpath = false ) {
-               $this->output( "Dropping $index key from table $table... " );
                if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
+                       $this->output( "Dropping $index index from table $table... " );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "done.\n" );
                } else {
-                       $this->output( "...$index key doesn't exist in table $table, skipping drop key\n" );
+                       $this->output( "...$index key doesn't exist.\n" );
                }
        }
 
@@ -499,12 +515,12 @@ abstract class DatabaseUpdater {
         * @param $fullpath bool
         */
        protected function dropTable( $table, $patch, $fullpath = false ) {
-               $this->output( "Dropping table $table... " );
                if ( $this->db->tableExists( $table, __METHOD__ ) ) {
+                       $this->output( "Dropping table $table... " );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "done.\n" );
                } else {
-                       $this->output( "...$table doesn't exist, skipping drop table.\n" );
+                       $this->output( "...$table doesn't exist.\n" );
                }
        }
 
@@ -518,7 +534,6 @@ abstract class DatabaseUpdater {
         */
        public function modifyField( $table, $field, $patch, $fullpath = false ) {
                $updateKey = "$table-$field-$patch";
-               $this->output( "Modifying $field field of table $table... " );
                if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
                        $this->output( "...$table table does not exist, skipping modify field patch.\n" );
                } elseif ( !$this->db->fieldExists( $table, $field, __METHOD__ ) ) {
@@ -526,6 +541,7 @@ abstract class DatabaseUpdater {
                } elseif( $this->updateRowExists( $updateKey ) ) {
                        $this->output( "...$field in table $table already modified by patch $patch.\n" );
                } else {
+                       $this->output( "Modifying $field field of table $table..." );
                        $this->applyPatch( $patch, $fullpath );
                        $this->insertUpdateRow( $updateKey );
                        $this->output( "done.\n" );
@@ -547,7 +563,7 @@ abstract class DatabaseUpdater {
         * Check the site_stats table is not properly populated.
         */
        protected function checkStats() {
-               $this->output( "Checking site_stats row..." );
+               $this->output( "...site_stats is populated..." );
                $row = $this->db->selectRow( 'site_stats', '*', array( 'ss_row_id' => 1 ), __METHOD__ );
                if ( $row === false ) {
                        $this->output( "data is missing! rebuilding...\n" );
@@ -588,7 +604,7 @@ abstract class DatabaseUpdater {
                        $this->output(
                        "Populating log_user_text field, printing progress markers. For large\n" .
                        "databases, you may want to hit Ctrl-C and do this manually with\n" .
-                       "maintenance/populateLogUsertext.php..." );
+                       "maintenance/populateLogUsertext.php.\n" );
 
                        $task = $this->maintenance->runChild( 'PopulateLogUsertext' );
                        $task->execute();
@@ -616,12 +632,12 @@ abstract class DatabaseUpdater {
         * Updates the timestamps in the transcache table
         */
        protected function doUpdateTranscacheField() {
-               $this->output( "Converting tc_time from UNIX epoch to MediaWiki timestamp... " );
                if ( $this->updateRowExists( 'convert transcache field' ) ) {
                        $this->output( "...transcache tc_time already converted.\n" );
                        return;
                }
 
+               $this->output( "Converting tc_time from UNIX epoch to MediaWiki timestamp... " );
                $this->applyPatch( 'patch-tc-timestamp.sql' );
                $this->output( "done.\n" );
        }
@@ -630,7 +646,6 @@ abstract class DatabaseUpdater {
         * Update CategoryLinks collation
         */
        protected function doCollationUpdate() {
-               $this->output( "Updating category collations..." );
                global $wgCategoryCollation;
                if ( $this->db->selectField(
                        'categorylinks',
@@ -642,6 +657,7 @@ abstract class DatabaseUpdater {
                        return;
                }
 
+               $this->output( "Updating category collations..." );
                $task = $this->maintenance->runChild( 'UpdateCollation' );
                $task->execute();
                $this->output( "...done.\n" );
@@ -652,7 +668,6 @@ abstract class DatabaseUpdater {
         */
        protected function doMigrateUserOptions() {
                $cl = $this->maintenance->runChild( 'ConvertUserOptions', 'convertUserOptions.php' );
-               $this->output( "Migrating remaining user_options... " );
                $cl->execute();
                $this->output( "done.\n" );
        }