Fix master/replica race condition when creating null revisions
authorRoan Kattouw <roan.kattouw@gmail.com>
Sat, 3 Mar 2018 03:54:45 +0000 (19:54 -0800)
committerRoan Kattouw <roan.kattouw@gmail.com>
Sat, 3 Mar 2018 03:54:45 +0000 (19:54 -0800)
RevisionStore::newFromNullRevision() carefully reads the latest revision
from the master, but then forgets to instruct emulateMainSlot_1_29() to
do the same, so the lookup query for rev_text_id in the text table is
done against a replica.

This is not usually a problem for null revisions, but it is a problem
when editing a page and then immediately moving it: this causes a null
revision to be created based on a freshly created revision, which
doesn't yet exist on the replica.

Bug: T184670
Change-Id: Ied4db5ee770716ff3edb918d2be722934c79d0c7

includes/Storage/RevisionStore.php

index e13fc1f..e00deef 100644 (file)
@@ -613,7 +613,7 @@ class RevisionStore
 
                        $fields['title'] = Title::makeTitle( $current->page_namespace, $current->page_title );
 
-                       $mainSlot = $this->emulateMainSlot_1_29( $fields, 0, $title );
+                       $mainSlot = $this->emulateMainSlot_1_29( $fields, self::READ_LATEST, $title );
                        $revision = new MutableRevisionRecord( $title, $this->wikiId );
                        $this->initializeMutableRevisionFromArray( $revision, $fields );
                        $revision->setSlot( $mainSlot );