PostDatabaseUpdateMaintenance: childs checks updatelog already
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 12 Oct 2012 18:52:29 +0000 (20:52 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 12 Oct 2012 18:52:29 +0000 (20:52 +0200)
The parent class LoggedUpdateMaintenance of each update script is
checking the updatelog self.

Checking in update.php prevents the script to be run, when using --force
on update.php and updater is not outputting a skipped message

Change-Id: I6cdad807ee4e49983cedef168d4e697a5bd8b7e7

includes/installer/DatabaseUpdater.php
maintenance/update.php

index a575334..e00aef5 100644 (file)
@@ -54,6 +54,10 @@ abstract class DatabaseUpdater {
 
        protected $shared = false;
 
+       /**
+        * Scripts to run after database update
+        * Should be a subclass of LoggedUpdateMaintenance
+        */
        protected $postDatabaseUpdateMaintenance = array(
                'DeleteDefaultMessages',
                'PopulateRevisionLength',
@@ -254,6 +258,8 @@ abstract class DatabaseUpdater {
        /**
         * Add a maintenance script to be run after the database updates are complete.
         *
+        * Script should subclass LoggedUpdateMaintenance
+        *
         * @since 1.19
         *
         * @param $class string Name of a Maintenance subclass
index 877f136..e3c993b 100644 (file)
@@ -126,12 +126,18 @@ class UpdateMediaWiki extends Maintenance {
                $updater->doUpdates( $updates );
 
                foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
-                       if ( $updater->updateRowExists( $maint ) ) {
+                       $child = $this->runChild( $maint );
+
+                       // LoggedUpdateMaintenance is checking the updatelog itself
+                       $isLoggedUpdate = ( $child instanceof LoggedUpdateMaintenance );
+
+                       if ( !$isLoggedUpdate && $updater->updateRowExists( $maint ) ) {
                                continue;
                        }
-                       $child = $this->runChild( $maint );
                        $child->execute();
-                       $updater->insertUpdateRow( $maint );
+                       if ( !$isLoggedUpdate ) {
+                               $updater->insertUpdateRow( $maint );
+                       }
                }
 
                $this->output( "\nDone.\n" );