Catrope has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/345386 )

Change subject: Implement WikiPage::getOldestRevision() in terms of 
Title::getFirstRevision()
......................................................................

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
---
M includes/Title.php
M includes/page/WikiPage.php
2 files changed, 4 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/86/345386/1

diff --git a/includes/Title.php b/includes/Title.php
index 0c5835c..f8d973c 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -4030,7 +4030,6 @@
                                __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 1d5973b..6d2cdeb 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -574,36 +574,12 @@
         * @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;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/345386
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21a118c6cd5c98fb846a0a2765574c0dbdbf7220
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to