64 parent::__construct( $article,
$context );
65 $this->contentHandlerFactory = $contentHandlerFactory;
66 $this->rollbackPageFactory = $rollbackPageFactory;
67 $this->userOptionsLookup = $userOptionsLookup;
68 $this->watchlistManager = $watchlistManager;
69 $this->commentFormatter = $commentFormatter;
112 $from = $this->
getRequest()->getVal(
'from' );
113 if ( $from ===
null ) {
114 throw new BadRequestError(
'rollbackfailed',
'rollback-missingparam' );
116 foreach ( [
'from',
'bot',
'hidediff',
'summary',
'token' ] as $param ) {
118 if ( $val !==
null ) {
134 if ( !$this->userOptionsLookup->getOption( $this->getUser(),
'showrollbackconfirmation' ) ||
135 $this->getRequest()->wasPosted()
139 $this->showRollbackConfirmationForm();
144 $this->enableTransactionalTimelimit();
145 $this->
getOutput()->addModuleStyles(
'mediawiki.interface.helpers.styles' );
149 $from = $request->getVal(
'from' );
151 if ( $from ===
null ) {
152 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingparam' );
155 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingrevision' );
158 $revUser = $rev->getUser();
159 $userText = $revUser ? $revUser->getName() :
'';
160 if ( $from !== $userText ) {
162 $this->
getTitle()->getPrefixedText(),
168 if ( !$user->matchEditToken( $request->getVal(
'token' ),
'rollback' ) ) {
169 throw new ErrorPageError(
'sessionfailure-title',
'sessionfailure' );
176 if ( $this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
177 $revUser = $rev->getUser( RevisionRecord::RAW );
180 $revUser = $userFactory->newFromName( $this->context->msg(
'rev-deleted-user' )->plain() );
184 $rollbackResult = $this->rollbackPageFactory
187 ->setSummary( $request->getText(
'summary' ) )
188 ->markAsBot( $request->getBool(
'bot' ) )
189 ->rollbackIfAllowed();
190 $data = $rollbackResult->getValue();
192 if ( $rollbackResult->hasMessage(
'actionthrottledtext' ) ) {
196 # NOTE: Permission errors already handled by Action::checkExecute.
197 if ( $rollbackResult->hasMessage(
'readonlytext' ) ) {
201 if ( $rollbackResult->getMessages() ) {
202 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'rollbackfailed' ) );
204 foreach ( $rollbackResult->getMessages() as $msg ) {
209 ( $rollbackResult->hasMessage(
'alreadyrolled' ) ||
210 $rollbackResult->hasMessage(
'cantrollback' ) ||
211 $rollbackResult->hasMessage(
'rollback-nochange' ) )
212 && isset( $data[
'current-revision-record'] )
215 $current = $data[
'current-revision-record'];
216 $comment = $current->getComment()?->text;
218 if ( $comment !==
null && $comment !==
'' ) {
222 $this->commentFormatter
233 $current = $data[
'current-revision-record'];
234 $target = $data[
'target-revision-record'];
235 $newId = $data[
'newid'];
236 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'actioncomplete' ) );
237 $this->
getOutput()->setRobotPolicy(
'noindex,nofollow' );
239 $old = Linker::revUserTools( $current );
240 $new = Linker::revUserTools( $target );
242 $currentUser = $current->getUser( RevisionRecord::FOR_THIS_USER, $user );
243 $targetUser = $target->getUser( RevisionRecord::FOR_THIS_USER, $user );
244 $userOptionsLookup = $this->userOptionsLookup;
246 $this->
msg(
'rollback-success' )
247 ->rawParams( $old, $new )
248 ->params( $currentUser ? $currentUser->getName() :
'' )
249 ->params( $targetUser ? $targetUser->getName() :
'' )
254 $this->
getOutput()->addModules(
'mediawiki.misc-authed-curate' );
258 'wgRollbackSuccess' =>
true,
261 'wgPostEditConfirmationDisabled' =>
true,
265 if ( $userOptionsLookup->
getBoolOption( $user,
'watchrollback' ) &&
266 !$this->watchlistManager->isWatchedIgnoringRights( $user, $this->getTitle() )
268 $this->watchlistManager->addWatchIgnoringRights( $user, $this->
getTitle(),
269 $userOptionsLookup->
getOption( $user,
'watchrollback-expiry' ) );
274 if ( !$request->getBool(
'hidediff',
false ) &&
275 !$userOptionsLookup->
getBoolOption( $this->getUser(),
'norollbackdiff' )
277 $contentModel = $current->getMainContentModel();
278 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
279 $de = $contentHandler->createDifferenceEngine(
286 $de->showDiff(
'',
'' );
294 private function enableTransactionalTimelimit() {
305 $trxProfiler->redefineExpectations( $trxLimits[
'POST'], $fname );
308 $trxProfiler->redefineExpectations( $trxLimits[
'PostSend-POST'], $fname );
313 private function showRollbackConfirmationForm() {
315 if ( $form->show() ) {
326 'default' => $this->
msg(
'confirm-rollback-bottom' )->parse()
333class_alias( RollbackAction::class,
'RollbackAction' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfTransactionalTimeLimit()
Raise the request time limit to $wgTransactionalTimeLimit.
An error page which can definitely be safely rendered using the OutputPage.
A class containing constants representing the names of configuration variables.
const TrxProfilerLimits
Name constant for the TrxProfilerLimits setting, for use with Config::get()
Legacy class representing an editable page and handling UI for some page actions.
Profiler base class that defines the interface and some shared functionality.
Interface for objects which can provide a MediaWiki context on request.
Service for page rollback actions.