Allow dumps to function with MCR in read-new mode.
authordaniel <daniel.kinzler@wikimedia.de>
Fri, 7 Sep 2018 12:12:12 +0000 (14:12 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Fri, 7 Sep 2018 12:18:40 +0000 (14:18 +0200)
This is a temporary fix that forces the dump code to continue to
use the old database schema, even when MCR is in
SCHEMA_COMPAT_READ_NEW mode. This will continue to function until
SCHEMA_COMPAT_WRITE_OLD  mode is disabled.

Bug: T198561
Change-Id: Ic54ee703f47d1843f70fdb7185ac1b098f148680

includes/export/WikiExporter.php

index 6c7a449..b018584 100644 (file)
@@ -263,6 +263,8 @@ class WikiExporter {
         * @throws Exception
         */
        protected function dumpFrom( $cond = '', $orderRevs = false ) {
+               global $wgMultiContentRevisionSchemaMigrationStage;
+
                # For logging dumps...
                if ( $this->history & self::LOGS ) {
                        $where = [];
@@ -330,8 +332,17 @@ class WikiExporter {
                        }
                # For page dumps...
                } else {
+                       if ( !( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) ) {
+                               // TODO: Make XmlDumpWriter use a RevisionStore! (see T198706 and T174031)
+                               throw new MWException(
+                                       'Cannot use WikiExporter with SCHEMA_COMPAT_WRITE_OLD mode disabled!'
+                                       . ' Support for dumping from the new schema is not implemented yet!'
+                               );
+                       }
+
                        $revOpts = [ 'page' ];
                        if ( $this->text != self::STUB ) {
+                               // TODO: remove the text and make XmlDumpWriter use a RevisionStore instead! (T198706)
                                $revOpts[] = 'text';
                        }
                        $revQuery = Revision::getQueryInfo( $revOpts );
@@ -343,7 +354,8 @@ class WikiExporter {
                        ];
                        unset( $join['page'] );
 
-                       $fields = array_merge( $revQuery['fields'], [ 'page_restrictions' ] );
+                       // TODO: remove rev_text_id and make XmlDumpWriter use a RevisionStore instead! (T198706)
+                       $fields = array_merge( $revQuery['fields'], [ 'page_restrictions, rev_text_id' ] );
 
                        $conds = [];
                        if ( $cond !== '' ) {