Merge "RevisionStoreDbTestBase, remove redundant needsDB override"
[lhc/web/wiklou.git] / includes / installer / DatabaseUpdater.php
index 939301d..82ccce2 100644 (file)
@@ -34,6 +34,8 @@ require_once __DIR__ . '/../../maintenance/Maintenance.php';
  * @since 1.17
  */
 abstract class DatabaseUpdater {
+       const REPLICATION_WAIT_TIMEOUT = 300;
+
        /**
         * Array of updates to perform on the database
         *
@@ -208,6 +210,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() ) {
@@ -483,7 +486,7 @@ abstract class DatabaseUpdater {
                        flush();
                        if ( $ret !== false ) {
                                $updatesDone[] = $origParams;
-                               $lbFactory->waitForReplication();
+                               $lbFactory->waitForReplication( [ 'timeout' => self::REPLICATION_WAIT_TIMEOUT ] );
                        } else {
                                $updatesSkipped[] = [ $func, $params, $origParams ];
                        }
@@ -1152,21 +1155,6 @@ abstract class DatabaseUpdater {
                }
        }
 
-       /**
-        * Updates the timestamps in the transcache table
-        * @return bool
-        */
-       protected function doUpdateTranscacheField() {
-               if ( $this->updateRowExists( 'convert transcache field' ) ) {
-                       $this->output( "...transcache tc_time already converted.\n" );
-
-                       return true;
-               }
-
-               return $this->applyPatch( 'patch-tc-timestamp.sql', false,
-                       "Converting tc_time from UNIX epoch to MediaWiki timestamp" );
-       }
-
        /**
         * Update CategoryLinks collation
         */
@@ -1362,4 +1350,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' );
+                       }
+               }
+       }
 }