aboutsummaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorDannyS712 <DannyS712.enwiki@gmail.com>2020-04-24 00:27:49 +0000
committerDannyS712 <DannyS712.enwiki@gmail.com>2020-05-16 08:37:41 +0000
commit30308ecc43ebceef7ff12eeb759fd29c53b236c4 (patch)
tree84faa2a7fad09c0791b7fae996aefb8b8e63a3fc /includes
parent9fb14c42aaa7ce2dad48e60205f548231b673e11 (diff)
downloadmediawikicore-30308ecc43ebceef7ff12eeb759fd29c53b236c4.tar.gz
mediawikicore-30308ecc43ebceef7ff12eeb759fd29c53b236c4.zip
RollbackAction: Reduce uses of Revision objects
WikiPage::doRollback passes Revision objects back to the caller, immediately convert to RevisionRecord and only use the RevisionRecord, will make eventual changes to stop returning Revision easier. Removes uses of Revision::getUserText and ::getContentHandler as well. Bug: T250579 Bug: T250981 Change-Id: Id812546ff24d7aa4fe11034a2beab51660bbbf45
Diffstat (limited to 'includes')
-rw-r--r--includes/actions/RollbackAction.php35
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(),