Revision->insertOn: Set READ_LATEST flag
authorMatthew Flaschen <mflaschen@wikimedia.org>
Thu, 6 Oct 2016 04:31:30 +0000 (00:31 -0400)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Thu, 6 Oct 2016 04:31:30 +0000 (00:31 -0400)
Inserting new revisions requires master by definition.  Without this,
there can be problems when creating multiple revisions in a
transaction (i.e. a null revision pointed to a text_id borrowed
from a just-created revision).

Bug: T138310
Change-Id: I10773612f04b6525f9c8bc27a96bcb8a77831816

includes/Revision.php

index ddbe646..208652f 100644 (file)
@@ -1395,6 +1395,11 @@ class Revision implements IDBAccessObject {
        public function insertOn( $dbw ) {
                global $wgDefaultExternalStore, $wgContentHandlerUseDB;
 
+               // We're inserting a new revision, so we have to use master anyway.
+               // If it's a null revision, it may have references to rows that
+               // are not in the replica yet (the text row).
+               $this->mQueryFlags |= self::READ_LATEST;
+
                // Not allowed to have rev_page equal to 0, false, etc.
                if ( !$this->mPage ) {
                        $title = $this->getTitle();