Merge "Use a closure instead of PathRouterPatternReplacer"
[lhc/web/wiklou.git] / includes / installer / DatabaseUpdater.php
index 4fc04db..e49a846 100644 (file)
@@ -109,7 +109,7 @@ abstract class DatabaseUpdater {
        /**
         * @param Database &$db To perform updates on
         * @param bool $shared Whether to perform updates on shared tables
-        * @param Maintenance $maintenance Maintenance object which created us
+        * @param Maintenance|null $maintenance Maintenance object which created us
         */
        protected function __construct( Database &$db, $shared, Maintenance $maintenance = null ) {
                $this->db = $db;
@@ -208,6 +208,7 @@ abstract class DatabaseUpdater {
         * Output some text. If we're running from web, escape the text first.
         *
         * @param string $str Text to output
+        * @param-taint $str escapes_html
         */
        public function output( $str ) {
                if ( $this->maintenance->isQuiet() ) {
@@ -410,9 +411,9 @@ abstract class DatabaseUpdater {
 
                foreach ( $updates as $funcList ) {
                        $func = $funcList[0];
-                       $arg = $funcList[1];
+                       $args = $funcList[1];
                        $origParams = $funcList[2];
-                       call_user_func_array( $func, $arg );
+                       $func( ...$args );
                        flush();
                        $this->updatesSkipped[] = $origParams;
                }
@@ -479,7 +480,7 @@ abstract class DatabaseUpdater {
                        } elseif ( $passSelf ) {
                                array_unshift( $params, $this );
                        }
-                       $ret = call_user_func_array( $func, $params );
+                       $ret = $func( ...$params );
                        flush();
                        if ( $ret !== false ) {
                                $updatesDone[] = $origParams;
@@ -516,7 +517,7 @@ abstract class DatabaseUpdater {
         * Obviously, only use this for updates that occur after the updatelog table was
         * created!
         * @param string $key Name of key to insert
-        * @param string $val [optional] Value to insert along with the key
+        * @param string|null $val [optional] Value to insert along with the key
         */
        public function insertUpdateRow( $key, $val = null ) {
                $this->db->clearFlag( DBO_DDLMODE );
@@ -659,7 +660,7 @@ abstract class DatabaseUpdater {
         *
         * @param string $path Path to the patch file
         * @param bool $isFullPath Whether to treat $path as a relative or not
-        * @param string $msg Description of the patch
+        * @param string|null $msg Description of the patch
         * @return bool False if patch is skipped.
         */
        protected function applyPatch( $path, $isFullPath = false, $msg = null ) {
@@ -1362,4 +1363,29 @@ abstract class DatabaseUpdater {
                        $this->output( "done.\n" );
                }
        }
+
+       /**
+        * Populates the MCR content tables
+        * @since 1.32
+        */
+       protected function populateContentTables() {
+               global $wgMultiContentRevisionSchemaMigrationStage;
+               if ( ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) &&
+                       !$this->updateRowExists( 'PopulateContentTables' )
+               ) {
+                       $this->output(
+                               "Migrating revision data to the MCR 'slot' and 'content' tables, printing progress markers.\n" .
+                               "For large databases, you may want to hit Ctrl-C and do this manually with\n" .
+                               "maintenance/populateContentTables.php.\n"
+                       );
+                       $task = $this->maintenance->runChild(
+                               PopulateContentTables::class, 'populateContentTables.php'
+                       );
+                       $ok = $task->execute();
+                       $this->output( $ok ? "done.\n" : "errors were encountered.\n" );
+                       if ( $ok ) {
+                               $this->insertUpdateRow( 'PopulateContentTables' );
+                       }
+               }
+       }
 }