From 69f9a18e461584d6a7240276baca13d037644d06 Mon Sep 17 00:00:00 2001 From: addshore Date: Thu, 28 Dec 2017 18:48:55 +0000 Subject: [PATCH] Revert "[MCR] Add and use $title param to RevisionStore getPrevious/Next" This reverts commit a760526bb41df8a46f70b498a2059323a99a683c. This is a PARTIAL revert and the changes to the follwing methods remain: - Revision::newFromArchiveRow This is no longer needed as the underlying issue has been fixed in commit 4de36baa63afc23398f5d1747f08fc47309c314c I15e4663902e2cbfe15b0da2e46449330e313bd0d Change-Id: I3e0ae29e62d59bcb4be871ef5b389a673ce8f103 --- includes/Revision.php | 13 ++++--------- includes/Storage/RevisionStore.php | 14 ++++---------- includes/page/PageArchive.php | 19 +++++-------------- 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/includes/Revision.php b/includes/Revision.php index 9a293866c1..7d38b4e254 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -145,7 +145,6 @@ class Revision implements IDBAccessObject { * * @param object $row * @param array $overrides - * @param Title $title (optional) * * @throws MWException * @return Revision @@ -895,10 +894,8 @@ class Revision implements IDBAccessObject { * @return Revision|null */ public function getPrevious() { - $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord, $this->getTitle() ); - return $rec === null - ? null - : new Revision( $rec, self::READ_NORMAL, $this->getTitle() ); + $rec = self::getRevisionStore()->getPreviousRevision( $this->mRecord ); + return $rec === null ? null : new Revision( $rec ); } /** @@ -907,10 +904,8 @@ class Revision implements IDBAccessObject { * @return Revision|null */ public function getNext() { - $rec = self::getRevisionStore()->getNextRevision( $this->mRecord, $this->getTitle() ); - return $rec === null - ? null - : new Revision( $rec, self::READ_NORMAL, $this->getTitle() ); + $rec = self::getRevisionStore()->getNextRevision( $this->mRecord ); + return $rec === null ? null : new Revision( $rec ); } /** diff --git a/includes/Storage/RevisionStore.php b/includes/Storage/RevisionStore.php index b571294f2a..c22ed307e2 100644 --- a/includes/Storage/RevisionStore.php +++ b/includes/Storage/RevisionStore.php @@ -1678,14 +1678,11 @@ 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 $title = null ) { - if ( $title === null ) { - $title = $this->getTitle( $rev->getPageId(), $rev->getId() ); - } + public function getPreviousRevision( RevisionRecord $rev ) { + $title = $this->getTitle( $rev->getPageId(), $rev->getId() ); $prev = $title->getPreviousRevisionID( $rev->getId() ); if ( $prev ) { return $this->getRevisionByTitle( $title, $prev ); @@ -1699,14 +1696,11 @@ 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 $title = null ) { - if ( $title === null ) { - $title = $this->getTitle( $rev->getPageId(), $rev->getId() ); - } + public function getNextRevision( RevisionRecord $rev ) { + $title = $this->getTitle( $rev->getPageId(), $rev->getId() ); $next = $title->getNextRevisionID( $rev->getId() ); if ( $next ) { return $this->getRevisionByTitle( $title, $next ); diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php index 0ef038f8dc..05247cafeb 100644 --- a/includes/page/PageArchive.php +++ b/includes/page/PageArchive.php @@ -255,11 +255,7 @@ class PageArchive { ); if ( $row ) { - return Revision::newFromArchiveRow( - $row, - [ 'title' => $this->title ], - $this->title - ); + return Revision::newFromArchiveRow( $row, [ 'title' => $this->title ] ); } return null; @@ -608,12 +604,10 @@ 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 ); @@ -676,15 +670,12 @@ 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 ); -- 2.20.1