From: Roan Kattouw Date: Wed, 29 Mar 2017 15:53:08 +0000 (-0400) Subject: Implement WikiPage::getOldestRevision() in terms of Title::getFirstRevision() X-Git-Tag: 1.31.0-rc.0~3656^2 X-Git-Url: http://git.cyclocoop.org/%24dirpuce/puce%24spip_lang_rtl.gif?a=commitdiff_plain;h=09f14cba5219c49ccc070afd5f820e4ccec1a700;p=lhc%2Fweb%2Fwiklou.git Implement WikiPage::getOldestRevision() in terms of Title::getFirstRevision() They were both doing the same thing, except that getOldestRevision() checks the master if the revision is missing on the replica. Change-Id: I21a118c6cd5c98fb846a0a2765574c0dbdbf7220 --- diff --git a/includes/Title.php b/includes/Title.php index 0c5835ca42..f8d973c6b3 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4030,7 +4030,6 @@ class Title implements LinkTarget { __METHOD__, [ 'ORDER BY' => 'rev_timestamp ASC', - 'LIMIT' => 1, 'IGNORE INDEX' => 'rev_timestamp' ] ); diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 1d5973b809..6d2cdebe75 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -574,36 +574,12 @@ class WikiPage implements Page, IDBAccessObject { * @return Revision|null */ public function getOldestRevision() { - // Try using the replica DB first, then try the master - $continue = 2; - $db = wfGetDB( DB_REPLICA ); - $revSelectFields = Revision::selectFields(); - - $row = null; - while ( $continue ) { - $row = $db->selectRow( - [ 'revision' ], - $revSelectFields, - [ - 'rev_page' => $this->getId() - ], - __METHOD__, - [ - 'ORDER BY' => 'rev_timestamp ASC', - 'IGNORE INDEX' => 'rev_timestamp' - ] - ); - - if ( $row ) { - $continue = 0; - } else { - $db = wfGetDB( DB_MASTER ); - $continue--; - } + $rev = $this->mTitle->getFirstRevision(); + if ( !$rev ) { + $rev = $this->mTitle->getFirstRevision( Title::GAID_FOR_UPDATE ); } - - return $row ? Revision::newFromRow( $row ) : null; + return $rev; } /**