69 parent::__construct( $article, $context );
70 $this->contentHandlerFactory = $contentHandlerFactory;
71 $this->rollbackPageFactory = $rollbackPageFactory;
72 $this->userOptionsLookup = $userOptionsLookup;
73 $this->watchlistManager = $watchlistManager;
74 $this->commentFormatter = $commentFormatter;
142 $this->enableTransactionalTimelimit();
143 $this->
getOutput()->addModuleStyles(
'mediawiki.interface.helpers.styles' );
147 $from = $request->getVal(
'from' );
149 if ( $from ===
null ) {
150 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingparam' );
153 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingrevision' );
156 $revUser = $rev->getUser();
157 $userText = $revUser ? $revUser->getName() :
'';
158 if ( $from !== $userText ) {
160 $this->
getTitle()->getPrefixedText(),
166 if ( !$user->matchEditToken( $request->getVal(
'token' ),
'rollback' ) ) {
167 throw new ErrorPageError(
'sessionfailure-title',
'sessionfailure' );
174 if ( $this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
175 $revUser = $rev->getUser( RevisionRecord::RAW );
177 $userFactory = MediaWikiServices::getInstance()->getUserFactory();
178 $revUser = $userFactory->newFromName( $this->context->msg(
'rev-deleted-user' )->plain() );
182 $rollbackResult = $this->rollbackPageFactory
185 ->setSummary( $request->getText(
'summary' ) )
186 ->markAsBot( $request->getBool(
'bot' ) )
187 ->rollbackIfAllowed();
188 $data = $rollbackResult->getValue();
190 if ( $rollbackResult->hasMessage(
'actionthrottledtext' ) ) {
194 if ( $rollbackResult->hasMessage(
'alreadyrolled' ) || $rollbackResult->hasMessage(
'cantrollback' ) ) {
195 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'rollbackfailed' ) );
196 $errArray = $rollbackResult->getErrors()[0];
197 $this->
getOutput()->addWikiMsgArray( $errArray[
'message'], $errArray[
'params'] );
199 if ( isset( $data[
'current-revision-record'] ) ) {
201 $current = $data[
'current-revision-record'];
203 if ( $current->getComment() !=
null ) {
207 $this->commentFormatter
208 ->format( $current->getComment()->text )
217 # NOTE: Permission errors already handled by Action::checkExecute.
218 if ( $rollbackResult->hasMessage(
'readonlytext' ) ) {
222 # XXX: Would be nice if ErrorPageError could take multiple errors, and/or a status object.
223 # Right now, we only show the first error
224 foreach ( $rollbackResult->getErrors() as $error ) {
225 throw new ErrorPageError(
'rollbackfailed', $error[
'message'], $error[
'params'] );
229 $current = $data[
'current-revision-record'];
230 $target = $data[
'target-revision-record'];
231 $newId = $data[
'newid'];
232 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'actioncomplete' ) );
233 $this->
getOutput()->setRobotPolicy(
'noindex,nofollow' );
235 $old = Linker::revUserTools( $current );
236 $new = Linker::revUserTools( $target );
238 $currentUser = $current->getUser( RevisionRecord::FOR_THIS_USER, $user );
239 $targetUser = $target->getUser( RevisionRecord::FOR_THIS_USER, $user );
241 $this->
msg(
'rollback-success' )
242 ->rawParams( $old, $new )
243 ->params( $currentUser ? $currentUser->getName() :
'' )
244 ->params( $targetUser ? $targetUser->getName() :
'' )
249 $this->
getOutput()->addModules(
'mediawiki.misc-authed-curate' );
253 'wgRollbackSuccess' =>
true,
256 'wgPostEditConfirmationDisabled' =>
true,
259 if ( $this->userOptionsLookup->getBoolOption( $user,
'watchrollback' ) ) {
260 $this->watchlistManager->addWatchIgnoringRights( $user, $this->
getTitle() );
265 if ( !$request->getBool(
'hidediff',
false ) &&
266 !$this->userOptionsLookup->getBoolOption( $this->getUser(),
'norollbackdiff' )
268 $contentModel = $current->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )
270 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
271 $de = $contentHandler->createDifferenceEngine(
278 $de->showDiff(
'',
'' );
298 DeferredUpdates::addCallableUpdate(
static function () use ( $trxProfiler, $trxLimits, $fname