diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2020-05-20 20:49:24 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2020-05-20 20:49:24 +0000 |
commit | b04b606bcfdd6b41442e0ac02794d7713cc528f6 (patch) | |
tree | 5584e4b636ac4e3b2b667c3bd4b8e834241e3cdd /includes | |
parent | 97bf695d698a2b6b41a0398c603ad18e6b968657 (diff) | |
parent | 30308ecc43ebceef7ff12eeb759fd29c53b236c4 (diff) | |
download | mediawikicore-b04b606bcfdd6b41442e0ac02794d7713cc528f6.tar.gz mediawikicore-b04b606bcfdd6b41442e0ac02794d7713cc528f6.zip |
Merge "RollbackAction: Reduce uses of Revision objects"
Diffstat (limited to 'includes')
-rw-r--r-- | includes/actions/RollbackAction.php | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php index 9719b15ae6fc..4467c7a6b56c 100644 --- a/includes/actions/RollbackAction.php +++ b/includes/actions/RollbackAction.php @@ -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(), |