Remove usages of Title::get{Previous,Next}RevisionId
The methods were deprecated since 1.34. Change-Id: Ib95ac1ba36a8ffd6b71ed67642d8abb2e3538bae
This commit is contained in:
parent
e19e6bfabc
commit
56c21d059c
8 changed files with 101 additions and 43 deletions
|
|
@ -433,27 +433,30 @@ class HistoryAction extends FormlessAction {
|
|||
* @return FeedItem
|
||||
*/
|
||||
function feedItem( $row ) {
|
||||
$rev = new Revision( $row, 0, $this->getTitle() );
|
||||
|
||||
$revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
|
||||
$rev = $revisionStore->newRevisionFromRow( $row, 0, $this->getTitle() );
|
||||
$prevRev = $revisionStore->getPreviousRevision( $rev );
|
||||
$revComment = $rev->getComment() === null ? null : $rev->getComment()->text;
|
||||
$text = FeedUtils::formatDiffRow(
|
||||
$this->getTitle(),
|
||||
$this->getTitle()->getPreviousRevisionID( $rev->getId() ),
|
||||
$prevRev ? $prevRev->getId() : false,
|
||||
$rev->getId(),
|
||||
$rev->getTimestamp(),
|
||||
$rev->getComment()
|
||||
$revComment
|
||||
);
|
||||
if ( $rev->getComment() == '' ) {
|
||||
$revUserText = $rev->getUser() ? $rev->getUser()->getName() : '';
|
||||
if ( $revComment == '' ) {
|
||||
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
||||
$title = $this->msg( 'history-feed-item-nocomment',
|
||||
$rev->getUserText(),
|
||||
$revUserText,
|
||||
$contLang->timeanddate( $rev->getTimestamp() ),
|
||||
$contLang->date( $rev->getTimestamp() ),
|
||||
$contLang->time( $rev->getTimestamp() )
|
||||
)->inContentLanguage()->text();
|
||||
} else {
|
||||
$title = $rev->getUserText() .
|
||||
$title = $revUserText .
|
||||
$this->msg( 'colon-separator' )->inContentLanguage()->text() .
|
||||
FeedItem::stripComment( $rev->getComment() );
|
||||
FeedItem::stripComment( $revComment );
|
||||
}
|
||||
|
||||
return new FeedItem(
|
||||
|
|
@ -461,7 +464,7 @@ class HistoryAction extends FormlessAction {
|
|||
$text,
|
||||
$this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
|
||||
$rev->getTimestamp(),
|
||||
$rev->getUserText(),
|
||||
$revUserText,
|
||||
$this->getTitle()->getTalkPage()->getFullURL()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,23 +238,31 @@ class RawAction extends FormlessAction {
|
|||
*/
|
||||
public function getOldId() {
|
||||
$oldid = $this->getRequest()->getInt( 'oldid' );
|
||||
$rl = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||
switch ( $this->getRequest()->getText( 'direction' ) ) {
|
||||
case 'next':
|
||||
# output next revision, or nothing if there isn't one
|
||||
$nextid = 0;
|
||||
$nextRev = null;
|
||||
if ( $oldid ) {
|
||||
$nextid = $this->getTitle()->getNextRevisionID( $oldid );
|
||||
$oldRev = $rl->getRevisionById( $oldid );
|
||||
if ( $oldRev ) {
|
||||
$nextRev = $rl->getNextRevision( $oldRev );
|
||||
}
|
||||
}
|
||||
$oldid = $nextid ?: -1;
|
||||
$oldid = $nextRev ? $nextRev->getId() : -1;
|
||||
break;
|
||||
case 'prev':
|
||||
# output previous revision, or nothing if there isn't one
|
||||
$prevRev = null;
|
||||
if ( !$oldid ) {
|
||||
# get the current revision so we can get the penultimate one
|
||||
$oldid = $this->page->getLatest();
|
||||
}
|
||||
$previd = $this->getTitle()->getPreviousRevisionID( $oldid );
|
||||
$oldid = $previd ?: -1;
|
||||
$oldRev = $rl->getRevisionById( $oldid );
|
||||
if ( $oldRev ) {
|
||||
$prevRev = $rl->getPreviousRevision( $oldRev );
|
||||
}
|
||||
$oldid = $prevRev ? $prevRev->getId() : -1;
|
||||
break;
|
||||
case 'cur':
|
||||
$oldid = 0;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Storage\RevisionRecord;
|
||||
|
||||
/**
|
||||
|
|
@ -239,11 +240,15 @@ class ApiEditPage extends ApiBase {
|
|||
$params['text'] = $newContent->serialize( $contentFormat );
|
||||
// If no summary was given and we only undid one rev,
|
||||
// use an autosummary
|
||||
if ( is_null( $params['summary'] ) &&
|
||||
$titleObj->getNextRevisionID( $undoafterRev->getId() ) == $params['undo']
|
||||
) {
|
||||
$params['summary'] = wfMessage( 'undo-summary' )
|
||||
->params( $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
|
||||
|
||||
if ( is_null( $params['summary'] ) ) {
|
||||
$nextRev = MediaWikiServices::getInstance()->getRevisionLookup()
|
||||
->getNextRevision( $undoafterRev->getRevisionRecord() );
|
||||
if ( $nextRev && $nextRev->getId() == $params['undo'] ) {
|
||||
$params['summary'] = wfMessage( 'undo-summary' )
|
||||
->params( $params['undo'], $undoRev->getUserText() )
|
||||
->inContentLanguage()->text();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,13 +93,14 @@ class ApiSetNotificationTimestamp extends ApiBase {
|
|||
$titles = $pageSet->getGoodTitles();
|
||||
$title = reset( $titles );
|
||||
if ( $title ) {
|
||||
$revid = $title->getNextRevisionID( $params['newerthanrevid'], Title::READ_LATEST );
|
||||
if ( $revid ) {
|
||||
$timestamp = $dbw->timestamp(
|
||||
MediaWikiServices::getInstance()->getRevisionStore()->getTimestampFromId( $title, $revid )
|
||||
);
|
||||
} else {
|
||||
$timestamp = null;
|
||||
$timestamp = null;
|
||||
$rl = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||
$currRev = $rl->getRevisionById( $params['newerthanrevid'], Title::READ_LATEST );
|
||||
if ( $currRev ) {
|
||||
$nextRev = $rl->getNextRevision( $currRev, Title::READ_LATEST );
|
||||
if ( $nextRev ) {
|
||||
$timestamp = $dbw->timestamp( $nextRev->getTimestamp() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Storage\RevisionRecord;
|
||||
|
||||
/**
|
||||
|
|
@ -273,11 +274,15 @@ class CategoryMembershipChange {
|
|||
* @return null|string
|
||||
*/
|
||||
private function getPreviousRevisionTimestamp() {
|
||||
$previousRev = Revision::newFromId(
|
||||
$this->pageTitle->getPreviousRevisionID( $this->pageTitle->getLatestRevID() )
|
||||
);
|
||||
|
||||
return $previousRev ? $previousRev->getTimestamp() : null;
|
||||
$rl = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||
$latestRev = $rl->getRevisionByTitle( $this->pageTitle );
|
||||
if ( $latestRev ) {
|
||||
$previousRev = $rl->getPreviousRevision( $latestRev );
|
||||
if ( $previousRev ) {
|
||||
return $previousRev->getTimestamp();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1713,14 +1713,29 @@ class DifferenceEngine extends ContextSource {
|
|||
* false signifies that there is no previous/next revision ($old is the oldest/newest one).
|
||||
*/
|
||||
public function mapDiffPrevNext( $old, $new ) {
|
||||
$rl = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||
if ( $new === 'prev' ) {
|
||||
// Show diff between revision $old and the previous one. Get previous one from DB.
|
||||
$newid = intval( $old );
|
||||
$oldid = $this->getTitle()->getPreviousRevisionID( $newid );
|
||||
$oldid = false;
|
||||
$newRev = $rl->getRevisionById( $newid );
|
||||
if ( $newRev ) {
|
||||
$oldRev = $rl->getPreviousRevision( $newRev );
|
||||
if ( $oldRev ) {
|
||||
$oldid = $oldRev->getId();
|
||||
}
|
||||
}
|
||||
} elseif ( $new === 'next' ) {
|
||||
// Show diff between revision $old and the next one. Get next one from DB.
|
||||
$oldid = intval( $old );
|
||||
$newid = $this->getTitle()->getNextRevisionID( $oldid );
|
||||
$newid = false;
|
||||
$oldRev = $rl->getRevisionById( $oldid );
|
||||
if ( $oldRev ) {
|
||||
$newRev = $rl->getNextRevision( $oldRev );
|
||||
if ( $newRev ) {
|
||||
$newid = $newRev->getId();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$oldid = intval( $old );
|
||||
$newid = intval( $new );
|
||||
|
|
|
|||
|
|
@ -363,8 +363,16 @@ class Article implements Page {
|
|||
}
|
||||
}
|
||||
|
||||
$rl = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||
$oldRev = $this->mRevision ? $this->mRevision->getRevisionRecord() : null;
|
||||
if ( $request->getVal( 'direction' ) == 'next' ) {
|
||||
$nextid = $this->getTitle()->getNextRevisionID( $oldid );
|
||||
$nextid = 0;
|
||||
if ( $oldRev ) {
|
||||
$nextRev = $rl->getNextRevision( $oldRev );
|
||||
if ( $nextRev ) {
|
||||
$nextid = $nextRev->getId();
|
||||
}
|
||||
}
|
||||
if ( $nextid ) {
|
||||
$oldid = $nextid;
|
||||
$this->mRevision = null;
|
||||
|
|
@ -372,7 +380,13 @@ class Article implements Page {
|
|||
$this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
|
||||
}
|
||||
} elseif ( $request->getVal( 'direction' ) == 'prev' ) {
|
||||
$previd = $this->getTitle()->getPreviousRevisionID( $oldid );
|
||||
$previd = 0;
|
||||
if ( $oldRev ) {
|
||||
$prevRev = $rl->getPreviousRevision( $oldRev );
|
||||
if ( $prevRev ) {
|
||||
$previd = $prevRev->getId();
|
||||
}
|
||||
}
|
||||
if ( $previd ) {
|
||||
$oldid = $previd;
|
||||
$this->mRevision = null;
|
||||
|
|
@ -1599,8 +1613,9 @@ class Article implements Page {
|
|||
'oldid' => $oldid
|
||||
] + $extraParams
|
||||
);
|
||||
$prev = $this->getTitle()->getPreviousRevisionID( $oldid );
|
||||
$prevlink = $prev
|
||||
$rl = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||
$prevExist = (bool)$rl->getPreviousRevision( $revision->getRevisionRecord() );
|
||||
$prevlink = $prevExist
|
||||
? Linker::linkKnown(
|
||||
$this->getTitle(),
|
||||
$context->msg( 'previousrevision' )->escaped(),
|
||||
|
|
@ -1611,7 +1626,7 @@ class Article implements Page {
|
|||
] + $extraParams
|
||||
)
|
||||
: $context->msg( 'previousrevision' )->escaped();
|
||||
$prevdiff = $prev
|
||||
$prevdiff = $prevExist
|
||||
? Linker::linkKnown(
|
||||
$this->getTitle(),
|
||||
$context->msg( 'diff' )->escaped(),
|
||||
|
|
|
|||
|
|
@ -3738,11 +3738,17 @@ class User implements IDBAccessObject, UserIdentity {
|
|||
$this->setNewtalk( false );
|
||||
|
||||
// If there is a new, unseen, revision, use its timestamp
|
||||
$nextid = $oldid
|
||||
? $title->getNextRevisionID( $oldid, Title::READ_LATEST )
|
||||
: null;
|
||||
if ( $nextid ) {
|
||||
$this->setNewtalk( true, Revision::newFromId( $nextid ) );
|
||||
if ( $oldid ) {
|
||||
$rl = MediaWikiServices::getInstance()->getRevisionLookup();
|
||||
$oldRev = $rl->getRevisionById( $oldid, Title::READ_LATEST );
|
||||
if ( $oldRev ) {
|
||||
$newRev = $rl->getNextRevision( $oldRev );
|
||||
if ( $newRev ) {
|
||||
// TODO: actually no need to wrap in a revision,
|
||||
// setNewtalk really only needs a RevRecord
|
||||
$this->setNewtalk( true, new Revision( $newRev ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue