From: jenkins-bot Date: Fri, 22 Dec 2017 14:50:04 +0000 (+0000) Subject: Merge "[MCR] Add and use $title param to RevisionStore getPrevious/Next" X-Git-Tag: 1.31.0-rc.0~1124 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=df015f95c9c86cbff8c8be0e2a7fbfd51b0ff3c0;hp=918fee715de966760522725b28ab1c757b6cee46 Merge "[MCR] Add and use $title param to RevisionStore getPrevious/Next" --- diff --git a/includes/Revision.php b/includes/Revision.php index 54558a4931..f3307c64b3 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -142,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 ); } /** @@ -880,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() ); } /** @@ -890,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() ); } /** diff --git a/includes/Storage/RevisionStore.php b/includes/Storage/RevisionStore.php index 24b437f98f..44dab1368b 100644 --- a/includes/Storage/RevisionStore.php +++ b/includes/Storage/RevisionStore.php @@ -1679,11 +1679,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 ); @@ -1697,10 +1700,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 ) { + public function getNextRevision( RevisionRecord $rev, Title $title = null ) { + if ( $title === null ) { + $title = $this->getTitle( $rev->getPageId(), $rev->getId() ); + } $title = $this->getTitle( $rev->getPageId(), $rev->getId() ); $next = $title->getNextRevisionID( $rev->getId() ); if ( $next ) { diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php index 05247cafeb..0ef038f8dc 100644 --- a/includes/page/PageArchive.php +++ b/includes/page/PageArchive.php @@ -255,7 +255,11 @@ class PageArchive { ); if ( $row ) { - return Revision::newFromArchiveRow( $row, [ 'title' => $this->title ] ); + return Revision::newFromArchiveRow( + $row, + [ 'title' => $this->title ], + $this->title + ); } return null; @@ -604,10 +608,12 @@ class PageArchive { $oldPageId = (int)$latestRestorableRow->ar_page_id; // pass this to ArticleUndelete hook // grab the content to check consistency with global state before restoring the page. - $revision = Revision::newFromArchiveRow( $latestRestorableRow, + $revision = Revision::newFromArchiveRow( + $latestRestorableRow, [ 'title' => $article->getTitle(), // used to derive default content model - ] + ], + $article->getTitle() ); $user = User::newFromName( $revision->getUserText( Revision::RAW ), false ); $content = $revision->getContent( Revision::RAW ); @@ -670,12 +676,15 @@ class PageArchive { } // Insert one revision at a time...maintaining deletion status // unless we are specifically removing all restrictions... - $revision = Revision::newFromArchiveRow( $row, + $revision = Revision::newFromArchiveRow( + $row, [ 'page' => $pageId, 'title' => $this->title, 'deleted' => $unsuppress ? 0 : $row->ar_deleted - ] ); + ], + $this->title + ); // This will also copy the revision to ip_changes if it was an IP edit. $revision->insertOn( $dbw );