* (bug 32020) Improve messages output by the database updaters
authorSam Reed <reedy@users.mediawiki.org>
Sat, 19 Nov 2011 17:18:22 +0000 (17:18 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 19 Nov 2011 17:18:22 +0000 (17:18 +0000)
Patch by David Baumgarten

CREDITS
includes/installer/DatabaseUpdater.php

diff --git a/CREDITS b/CREDITS
index a176e49..e26d096 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -96,6 +96,7 @@ following names for their contribution to the product.
 * Dan Collins
 * Dan Nessett
 * Daniel Arnold
+* David Baumgarten
 * Denny Vrandecic
 * Edward Z. Yang
 * Erwin Dokter
index 0ae28b7..907c00f 100644 (file)
@@ -412,10 +412,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.\n" );
+                       $this->output( "...$name table already exists. Skipping create table $name\n" );
                } else {
-                       $this->output( "Creating $name table..." );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "ok\n" );
                }
@@ -429,12 +429,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( "...have $field field in $table table.\n" );
+                       $this->output( "...already have $field field in $table table, skipping new field patch\n" );
                } else {
-                       $this->output( "Adding $field field to table $table..." );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "ok\n" );
                }
@@ -448,10 +448,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.\n" );
+                       $this->output( "...$index key already set on $table table, skipping new index patch\n" );
                } else {
-                       $this->output( "Adding $index key to table $table... " );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "ok\n" );
                }
@@ -466,12 +466,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( "ok\n" );
                } else {
-                       $this->output( "...$table table does not contain $field field.\n" );
+                       $this->output( "...$table table does not contain $field field, skipping drop field\n" );
                }
        }
 
@@ -484,12 +484,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 key from table $table... " );
                        $this->applyPatch( $patch, $fullpath );
                        $this->output( "ok\n" );
                } else {
-                       $this->output( "...$index key doesn't exist.\n" );
+                       $this->output( "...$index key doesn't exist in table $table, skipping drop key\n" );
                }
        }
 
@@ -499,12 +499,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( "ok\n" );
                } else {
-                       $this->output( "...$table doesn't exist.\n" );
+                       $this->output( "...$table doesn't exist, skipping drop table.\n" );
                }
        }
 
@@ -518,6 +518,7 @@ 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__ ) ) {
@@ -525,7 +526,6 @@ 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( "ok\n" );