resourceloader: Simplify makeLoaderStateScript and makeLoaderSourcesScript
[lhc/web/wiklou.git] / includes / Revision / RevisionStore.php
index 3ecef76..c444cc4 100644 (file)
@@ -182,9 +182,9 @@ class RevisionStore
                        'Reading needs to be enabled for the old or the new schema.'
                );
                Assert::parameter(
-                       ( $mcrMigrationStage & SCHEMA_COMPAT_WRITE_BOTH ) !== 0,
+                       ( $mcrMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) !== 0,
                        '$mcrMigrationStage',
-                       'Writing needs to be enabled for the old or the new schema.'
+                       'Writing needs to be enabled for the new schema.'
                );
                Assert::parameter(
                        ( $mcrMigrationStage & SCHEMA_COMPAT_READ_OLD ) === 0
@@ -192,12 +192,6 @@ class RevisionStore
                        '$mcrMigrationStage',
                        'Cannot read the old schema when not also writing it.'
                );
-               Assert::parameter(
-                       ( $mcrMigrationStage & SCHEMA_COMPAT_READ_NEW ) === 0
-                       || ( $mcrMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) !== 0,
-                       '$mcrMigrationStage',
-                       'Cannot read the new schema when not also writing it.'
-               );
 
                $this->loadBalancer = $loadBalancer;
                $this->blobStore = $blobStore;
@@ -1907,7 +1901,11 @@ class RevisionStore
         *               'content'- whether the actual content of the slots should be
         *               preloaded.
         * @param int $queryFlags
-        * @param Title|null $title
+        * @param Title|null $title The title to which all the revision rows belong, if there
+        *        is such a title and the caller has it handy, so we don't have to look it up again.
+        *        If this parameter is given and any of the rows has a rev_page_id that is different
+        *        from $title->getArticleID(), an InvalidArgumentException is thrown.
+        *
         * @return StatusValue a status with a RevisionRecord[] of successfully fetched revisions
         *                                         and an array of errors for the revisions failed to fetch.
         */
@@ -1924,7 +1922,10 @@ class RevisionStore
                $titlesByPageId = [];
                foreach ( $rows as $row ) {
                        if ( isset( $rowsByRevId[$row->rev_id] ) ) {
-                               throw new InvalidArgumentException( "Duplicate rows in newRevisionsFromBatch {$row->rev_id}" );
+                               $result->warning(
+                                       'internalerror',
+                                       "Duplicate rows in newRevisionsFromBatch, rev_id {$row->rev_id}"
+                               );
                        }
                        if ( $title && $row->rev_page != $title->getArticleID() ) {
                                throw new InvalidArgumentException(