Merge "[MCR] Add and use $title param to RevisionStore getPrevious/Next"
[lhc/web/wiklou.git] / includes / Revision.php
index ea73a61..f3307c6 100644 (file)
@@ -90,11 +90,12 @@ class Revision implements IDBAccessObject {
         *
         * @param int $id
         * @param int $flags (optional)
+        * @param Title $title (optional)
         * @return Revision|null
         */
-       public static function newFromId( $id, $flags = 0 ) {
-               $rec = self::getRevisionStore()->getRevisionById( $id, $flags );
-               return $rec === null ? null : new Revision( $rec, $flags );
+       public static function newFromId( $id, $flags = 0, Title $title = null ) {
+               $rec = self::getRevisionStore()->getRevisionById( $id, $flags, $title );
+               return $rec === null ? null : new Revision( $rec, $flags, $title );
        }
 
        /**
@@ -141,13 +142,14 @@ class Revision implements IDBAccessObject {
         *
         * @param object $row
         * @param array $overrides
+        * @param Title $title (optional)
         *
         * @throws MWException
         * @return Revision
         */
-       public static function newFromArchiveRow( $row, $overrides = [] ) {
-               $rec = self::getRevisionStore()->newRevisionFromArchiveRow( $row, 0, null, $overrides );
-               return new Revision( $rec );
+       public static function newFromArchiveRow( $row, $overrides = [], Title $title = null ) {
+               $rec = self::getRevisionStore()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
+               return new Revision( $rec, self::READ_NORMAL, $title );
        }
 
        /**
@@ -879,8 +881,10 @@ class Revision implements IDBAccessObject {
         * @return Revision|null
         */
        public function getPrevious() {
-               $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord );
-               return $rec === null ? null : new Revision( $rec );
+               $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord, $this->getTitle() );
+               return $rec === null
+                       ? null
+                       : new Revision( $rec, self::READ_NORMAL, $this->getTitle() );
        }
 
        /**
@@ -889,8 +893,10 @@ class Revision implements IDBAccessObject {
         * @return Revision|null
         */
        public function getNext() {
-               $rec = self::getRevisionStore()->getNextRevision( $this->mRecord );
-               return $rec === null ? null : new Revision( $rec );
+               $rec = self::getRevisionStore()->getNextRevision( $this->mRecord, $this->getTitle() );
+               return $rec === null
+                       ? null
+                       : new Revision( $rec, self::READ_NORMAL, $this->getTitle() );
        }
 
        /**
@@ -979,8 +985,10 @@ class Revision implements IDBAccessObject {
 
                $this->mRecord = $rec;
 
+               // Avoid PHP 7.1 warning of passing $this by reference
+               $revision = $this;
                // TODO: hard-deprecate in 1.32 (or even 1.31?)
-               Hooks::run( 'RevisionInsertComplete', [ $this, null, null ] );
+               Hooks::run( 'RevisionInsertComplete', [ &$revision, null, null ] );
 
                return $rec->getId();
        }