Merge "Revert "Revert "[MCR] Add and use $title param to RevisionStoregetPrevious...
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 10 Jan 2018 17:14:54 +0000 (17:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 10 Jan 2018 17:14:54 +0000 (17:14 +0000)
includes/Revision.php
includes/Storage/RevisionLookup.php
includes/Storage/RevisionStore.php

index 10b896b..0844e89 100644 (file)
@@ -923,8 +923,9 @@ class Revision implements IDBAccessObject {
         * @return Revision|null
         */
        public function getPrevious() {
-               $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord );
-               return $rec === null ? null : new Revision( $rec );
+               $title = $this->getTitle();
+               $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord, $title );
+               return $rec === null ? null : new Revision( $rec, self::READ_NORMAL, $title );
        }
 
        /**
@@ -933,8 +934,9 @@ class Revision implements IDBAccessObject {
         * @return Revision|null
         */
        public function getNext() {
-               $rec = self::getRevisionStore()->getNextRevision( $this->mRecord );
-               return $rec === null ? null : new Revision( $rec );
+               $title = $this->getTitle();
+               $rec = self::getRevisionStore()->getNextRevision( $this->mRecord, $title );
+               return $rec === null ? null : new Revision( $rec, self::READ_NORMAL, $title );
        }
 
        /**
index afe0f81..45cd184 100644 (file)
@@ -84,10 +84,11 @@ interface RevisionLookup extends IDBAccessObject {
         * MCR migration note: this replaces Revision::getPrevious
         *
         * @param RevisionRecord $rev
+        * @param Title $title if known (optional)
         *
         * @return RevisionRecord|null
         */
-       public function getPreviousRevision( RevisionRecord $rev );
+       public function getPreviousRevision( RevisionRecord $rev, Title $title = null );
 
        /**
         * Get next revision for this title
@@ -95,10 +96,11 @@ interface RevisionLookup extends IDBAccessObject {
         * MCR migration note: this replaces Revision::getNext
         *
         * @param RevisionRecord $rev
+        * @param Title $title if known (optional)
         *
         * @return RevisionRecord|null
         */
-       public function getNextRevision( RevisionRecord $rev );
+       public function getNextRevision( RevisionRecord $rev, Title $title = null );
 
        /**
         * Load a revision based on a known page ID and current revision ID from the DB
index 3101aea..e0ee06a 100644 (file)
@@ -1707,11 +1707,14 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
         * MCR migration note: this replaces Revision::getPrevious
         *
         * @param RevisionRecord $rev
+        * @param Title $title if known (optional)
         *
         * @return RevisionRecord|null
         */
-       public function getPreviousRevision( RevisionRecord $rev ) {
-               $title = $this->getTitle( $rev->getPageId(), $rev->getId() );
+       public function getPreviousRevision( RevisionRecord $rev, Title $title = null ) {
+               if ( $title === null ) {
+                       $title = $this->getTitle( $rev->getPageId(), $rev->getId() );
+               }
                $prev = $title->getPreviousRevisionID( $rev->getId() );
                if ( $prev ) {
                        return $this->getRevisionByTitle( $title, $prev );
@@ -1725,11 +1728,14 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
         * MCR migration note: this replaces Revision::getNext
         *
         * @param RevisionRecord $rev
+        * @param Title $title if known (optional)
         *
         * @return RevisionRecord|null
         */
-       public function getNextRevision( RevisionRecord $rev ) {
-               $title = $this->getTitle( $rev->getPageId(), $rev->getId() );
+       public function getNextRevision( RevisionRecord $rev, Title $title = null ) {
+               if ( $title === null ) {
+                       $title = $this->getTitle( $rev->getPageId(), $rev->getId() );
+               }
                $next = $title->getNextRevisionID( $rev->getId() );
                if ( $next ) {
                        return $this->getRevisionByTitle( $title, $next );