Merge "Move callers away from Title::GAID_FOR_UPDATE"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 10 Sep 2019 03:32:37 +0000 (03:32 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 10 Sep 2019 03:32:37 +0000 (03:32 +0000)
13 files changed:
includes/MovePage.php
includes/Revision.php
includes/Revision/RevisionStore.php
includes/api/ApiSetNotificationTimestamp.php
includes/cache/LinkCache.php
includes/deferred/LinksUpdate.php
includes/jobqueue/jobs/RefreshLinksJob.php
includes/page/WikiPage.php
includes/user/User.php
maintenance/cleanupTitles.php
tests/phpunit/includes/TitleTest.php
tests/phpunit/includes/api/ApiDeleteTest.php
tests/phpunit/includes/api/ApiRevisionDeleteTest.php

index 564c8f4..634e7af 100644 (file)
@@ -473,6 +473,7 @@ class MovePage {
 
                        $mp = new MovePage( $oldSubpage, $newSubpage );
                        $method = $checkPermissions ? 'moveIfAllowed' : 'move';
+                       /** @var Status $status */
                        $status = $mp->$method( $user, $reason, $createRedirect, $changeTags );
                        if ( $status->isOK() ) {
                                $status->setResult( true, $newSubpage->getPrefixedText() );
@@ -508,7 +509,7 @@ class MovePage {
 
                Hooks::run( 'TitleMoveStarting', [ $this->oldTitle, $this->newTitle, $user ] );
 
-               $pageid = $this->oldTitle->getArticleID( Title::GAID_FOR_UPDATE );
+               $pageid = $this->oldTitle->getArticleID( Title::READ_LATEST );
                $protected = $this->oldTitle->isProtected();
 
                // Do the actual move; if this fails, it will throw an MWException(!)
index 292d6ba..828f647 100644 (file)
@@ -1005,7 +1005,7 @@ class Revision implements IDBAccessObject {
 
                $comment = CommentStoreComment::newUnsavedComment( $summary, null );
 
-               $title = Title::newFromID( $pageId, Title::GAID_FOR_UPDATE );
+               $title = Title::newFromID( $pageId, Title::READ_LATEST );
                if ( $title === null ) {
                        return null;
                }
index 73f622a..735a212 100644 (file)
@@ -326,10 +326,10 @@ class RevisionStore
 
                $canUseTitleNewFromId = ( $pageId !== null && $pageId > 0 && $this->dbDomain === false );
                list( $dbMode, $dbOptions ) = DBAccessObjectUtils::getDBOptions( $queryFlags );
-               $titleFlags = ( $dbMode == DB_MASTER ? Title::GAID_FOR_UPDATE : 0 );
 
                // Loading by ID is best, but Title::newFromID does not support that for foreign IDs.
                if ( $canUseTitleNewFromId ) {
+                       $titleFlags = ( $dbMode == DB_MASTER ? Title::READ_LATEST : 0 );
                        // TODO: better foreign title handling (introduce TitleFactory)
                        $title = Title::newFromID( $pageId, $titleFlags );
                        if ( $title ) {
index d2bbe7b..7e9f56d 100644 (file)
@@ -93,7 +93,7 @@ class ApiSetNotificationTimestamp extends ApiBase {
                        $titles = $pageSet->getGoodTitles();
                        $title = reset( $titles );
                        if ( $title ) {
-                               $revid = $title->getNextRevisionID( $params['newerthanrevid'], Title::GAID_FOR_UPDATE );
+                               $revid = $title->getNextRevisionID( $params['newerthanrevid'], Title::READ_LATEST );
                                if ( $revid ) {
                                        $timestamp = $dbw->timestamp(
                                                MediaWikiServices::getInstance()->getRevisionStore()->getTimestampFromId( $title, $revid )
index 8018117..b2f2452 100644 (file)
@@ -89,6 +89,7 @@ class LinkCache {
         *
         * @param bool|null $update
         * @return bool
+        * @deprecated Since 1.34
         */
        public function forUpdate( $update = null ) {
                return wfSetVar( $this->mForUpdate, $update );
index 74e236f..8345ee6 100644 (file)
@@ -125,7 +125,7 @@ class LinksUpdate extends DataUpdate {
 
                if ( !$this->mId ) {
                        // NOTE: subclasses may initialize mId before calling this constructor!
-                       $this->mId = $title->getArticleID( Title::GAID_FOR_UPDATE );
+                       $this->mId = $title->getArticleID( Title::READ_LATEST );
                }
 
                if ( !$this->mId ) {
index b4046a6..33b05b8 100644 (file)
@@ -276,8 +276,8 @@ class RefreshLinksJob extends Job {
                $title = $page->getTitle();
                // Get the latest ID since acquirePageLock() in runForTitle() flushed the transaction.
                // This is used to detect edits/moves after loadPageData() but before the scope lock.
-               // The works around the chicken/egg problem of determining the scope lock key name.
-               $latest = $title->getLatestRevID( Title::GAID_FOR_UPDATE );
+               // The works around the chicken/egg problem of determining the scope lock key name
+               $latest = $title->getLatestRevID( Title::READ_LATEST );
 
                $triggeringRevisionId = $this->params['triggeringRevisionId'] ?? null;
                if ( $triggeringRevisionId && $triggeringRevisionId !== $latest ) {
index c167f3a..bad75da 100644 (file)
@@ -726,7 +726,7 @@ class WikiPage implements Page, IDBAccessObject {
                // Try using the replica DB first, then try the master
                $rev = $this->mTitle->getFirstRevision();
                if ( !$rev ) {
-                       $rev = $this->mTitle->getFirstRevision( Title::GAID_FOR_UPDATE );
+                       $rev = $this->mTitle->getFirstRevision( Title::READ_LATEST );
                }
                return $rev;
        }
index 6893bf4..3e84b0b 100644 (file)
@@ -3717,7 +3717,7 @@ class User implements IDBAccessObject, UserIdentity {
 
                                // If there is a new, unseen, revision, use its timestamp
                                $nextid = $oldid
-                                       ? $title->getNextRevisionID( $oldid, Title::GAID_FOR_UPDATE )
+                                       ? $title->getNextRevisionID( $oldid, Title::READ_LATEST )
                                        : null;
                                if ( $nextid ) {
                                        $this->setNewtalk( true, Revision::newFromId( $nextid ) );
index cad6122..5602e39 100644 (file)
@@ -133,7 +133,7 @@ class TitleCleanup extends TableCleanup {
         * @param Title $title
         */
        protected function moveInconsistentPage( $row, Title $title ) {
-               if ( $title->exists( Title::GAID_FOR_UPDATE )
+               if ( $title->exists( Title::READ_LATEST )
                        || $title->getInterwiki()
                        || !$title->canExist()
                ) {
index 18faeea..82ccb9a 100644 (file)
@@ -768,12 +768,12 @@ class TitleTest extends MediaWikiTestCase {
                $this->assertEquals(
                        false,
                        $title->exists(),
-                       'exists() should rely on link cache unless GAID_FOR_UPDATE is used'
+                       'exists() should rely on link cache unless READ_LATEST is used'
                );
                $this->assertEquals(
                        true,
-                       $title->exists( Title::GAID_FOR_UPDATE ),
-                       'exists() should re-query database when GAID_FOR_UPDATE is used'
+                       $title->exists( Title::READ_LATEST ),
+                       'exists() should re-query database when READ_LATEST is used'
                );
        }
 
index c68954c..d2bbc1f 100644 (file)
@@ -67,7 +67,7 @@ class ApiDeleteTest extends ApiTestCase {
                $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
                $jobs->execute();
 
-               $this->assertFalse( Title::newFromText( $name )->exists( Title::GAID_FOR_UPDATE ) );
+               $this->assertFalse( Title::newFromText( $name )->exists( Title::READ_LATEST ) );
        }
 
        public function testDeleteNonexistent() {
index a4ca8a1..5dcea65 100644 (file)
@@ -22,8 +22,7 @@ class ApiRevisionDeleteTest extends ApiTestCase {
                // Make a few edits for us to play with
                for ( $i = 1; $i <= 5; $i++ ) {
                        self::editPage( self::$page, MWCryptRand::generateHex( 10 ), 'summary' );
-                       $this->revs[] = Title::newFromText( self::$page )
-                               ->getLatestRevID( Title::GAID_FOR_UPDATE );
+                       $this->revs[] = Title::newFromText( self::$page )->getLatestRevID( Title::READ_LATEST );
                }
        }