[MCR] RevisionStore::getTitle, Fix flags passed to Title::newFromID
authoraddshore <addshorewiki@gmail.com>
Wed, 10 Jan 2018 16:17:40 +0000 (16:17 +0000)
committerAddshore <addshorewiki@gmail.com>
Wed, 10 Jan 2018 18:26:30 +0000 (18:26 +0000)
This was passing $queryFlags directly into Title::newFromID which
expects different flags.

Instead we now set Title::GAID_FOR_UPDATE if $queryFlags will end up
hitting the master.

Change-Id: I9c6e275c22fe74a98e79c54049afa4915a7f565d

includes/Storage/RevisionStore.php

index e0ee06a..78e789e 100644 (file)
@@ -176,18 +176,18 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
                        throw new InvalidArgumentException( '$pageId and $revId cannot both be 0 or null' );
                }
 
+               list( $dbMode, $dbOptions, , ) = DBAccessObjectUtils::getDBOptions( $queryFlags );
+               $titleFlags = $dbMode == DB_MASTER ? Title::GAID_FOR_UPDATE : 0;
                $title = null;
 
                // Loading by ID is best, but Title::newFromID does not support that for foreign IDs.
                if ( $pageId !== null && $pageId > 0 && $this->wikiId === false ) {
                        // TODO: better foreign title handling (introduce TitleFactory)
-                       $title = Title::newFromID( $pageId, $queryFlags );
+                       $title = Title::newFromID( $pageId, $titleFlags );
                }
 
                // rev_id is defined as NOT NULL, but this revision may not yet have been inserted.
                if ( !$title && $revId !== null && $revId > 0 ) {
-                       list( $dbMode, $dbOptions, , ) = DBAccessObjectUtils::getDBOptions( $queryFlags );
-
                        $dbr = $this->getDbConnectionRef( $dbMode );
                        // @todo: Title::getSelectFields(), or Title::getQueryInfo(), or something like that
                        $row = $dbr->selectRow(