When the title is already known use it.
This is similar to the issue fixed in
I714ee391caac9bc56ce4c037967e424b44d9c2fe.
As of this patch all methods within RevisionStore
that call getTitle internally also have an option
to pass in an already known Title object.
Bug: T183548
Change-Id: Ieabca1cf157fb667c75fc907b9da2917f71c61b3
*
* @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 );
}
/**
* @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() );
}
/**
* @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() );
}
/**
* 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 );
* 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 ) {
);
if ( $row ) {
- return Revision::newFromArchiveRow( $row, [ 'title' => $this->title ] );
+ return Revision::newFromArchiveRow(
+ $row,
+ [ 'title' => $this->title ],
+ $this->title
+ );
}
return null;
$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 );
}
// 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 );