Merge "RollbackAction: Reduce uses of Revision objects"

This commit is contained in:
jenkins-bot 2020-05-20 20:49:24 +00:00 committed by Gerrit Code Review
commit b04b606bcf

View file

@ -20,7 +20,9 @@
* @ingroup Actions
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
/**
* User interface for the rollback action
@ -133,14 +135,16 @@ class RollbackAction extends FormAction {
$this->getOutput()->addWikiMsgArray( $errMsg, $errArray );
if ( isset( $data['current'] ) ) {
/** @var Revision $current */
$current = $data['current'];
/** @var RevisionRecord $current */
$current = $data['current']->getRevisionRecord();
if ( $current->getComment() != '' ) {
if ( $current->getComment() != null ) {
$this->getOutput()->addWikiMsg(
'editcomment',
Message::rawParam(
Linker::formatComment( $current->getComment() )
Linker::formatComment(
$current->getComment()->text
)
)
);
}
@ -160,20 +164,23 @@ class RollbackAction extends FormAction {
throw new ErrorPageError( 'rollbackfailed', $error[0], array_slice( $error, 1 ) );
}
/** @var Revision $current */
$current = $data['current'];
$target = $data['target'];
/** @var RevisionRecord $current */
$current = $data['current']->getRevisionRecord();
$target = $data['target']->getRevisionRecord();
$newId = $data['newid'];
$this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
$this->getOutput()->setRobotPolicy( 'noindex,nofollow' );
$old = Linker::revUserTools( $current->getRevisionRecord() );
$new = Linker::revUserTools( $target->getRevisionRecord() );
$old = Linker::revUserTools( $current );
$new = Linker::revUserTools( $target );
$currentUser = $current->getUser( RevisionRecord::FOR_THIS_USER, $user );
$targetUser = $target->getUser( RevisionRecord::FOR_THIS_USER, $user );
$this->getOutput()->addHTML(
$this->msg( 'rollback-success' )
->rawParams( $old, $new )
->params( $current->getUserText( RevisionRecord::FOR_THIS_USER, $user ) )
->params( $target->getUserText( RevisionRecord::FOR_THIS_USER, $user ) )
->params( $currentUser ? $currentUser->getName() : '' )
->params( $targetUser ? $targetUser->getName() : '' )
->parseAsBlock()
);
@ -186,7 +193,11 @@ class RollbackAction extends FormAction {
if ( !$request->getBool( 'hidediff', false ) &&
!$this->getUser()->getBoolOption( 'norollbackdiff' )
) {
$contentHandler = $current->getContentHandler();
$contentModel = $current->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )
->getModel();
$contentHandler = MediaWikiServices::getInstance()
->getContentHandlerFactory()
->getContentHandler( $contentModel );
$de = $contentHandler->createDifferenceEngine(
$this->getContext(),
$current->getId(),