70 parent::__construct( $article, $context );
71 $this->contentHandlerFactory = $contentHandlerFactory;
72 $this->rollbackPageFactory = $rollbackPageFactory;
73 $this->userOptionsLookup = $userOptionsLookup;
74 $this->watchlistManager = $watchlistManager;
75 $this->commentFormatter = $commentFormatter;
111 $from = $this->
getRequest()->getVal(
'from' );
112 if ( $from ===
null ) {
113 throw new BadRequestError(
'rollbackfailed',
'rollback-missingparam' );
115 foreach ( [
'from',
'bot',
'hidediff',
'summary',
'token' ] as $param ) {
117 if ( $val !==
null ) {
133 if ( !$this->userOptionsLookup->getOption( $this->getUser(),
'showrollbackconfirmation' ) ||
134 $this->getRequest()->wasPosted()
138 $this->showRollbackConfirmationForm();
143 $this->enableTransactionalTimelimit();
144 $this->
getOutput()->addModuleStyles(
'mediawiki.interface.helpers.styles' );
148 $from = $request->getVal(
'from' );
150 if ( $from ===
null ) {
151 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingparam' );
154 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingrevision' );
157 $revUser = $rev->getUser();
158 $userText = $revUser ? $revUser->getName() :
'';
159 if ( $from !== $userText ) {
161 $this->
getTitle()->getPrefixedText(),
167 if ( !$user->matchEditToken( $request->getVal(
'token' ),
'rollback' ) ) {
168 throw new ErrorPageError(
'sessionfailure-title',
'sessionfailure' );
175 if ( $this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
176 $revUser = $rev->getUser( RevisionRecord::RAW );
178 $userFactory = MediaWikiServices::getInstance()->getUserFactory();
179 $revUser = $userFactory->newFromName( $this->context->msg(
'rev-deleted-user' )->plain() );
183 $rollbackResult = $this->rollbackPageFactory
186 ->setSummary( $request->getText(
'summary' ) )
187 ->markAsBot( $request->getBool(
'bot' ) )
188 ->rollbackIfAllowed();
189 $data = $rollbackResult->getValue();
191 if ( $rollbackResult->hasMessage(
'actionthrottledtext' ) ) {
195 # NOTE: Permission errors already handled by Action::checkExecute.
196 if ( $rollbackResult->hasMessage(
'readonlytext' ) ) {
200 if ( $rollbackResult->getMessages() ) {
201 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'rollbackfailed' ) );
203 foreach ( $rollbackResult->getMessages() as $msg ) {
208 ( $rollbackResult->hasMessage(
'alreadyrolled' ) || $rollbackResult->hasMessage(
'cantrollback' ) )
209 && isset( $data[
'current-revision-record'] )
212 $current = $data[
'current-revision-record'];
214 if ( $current->getComment() !=
null ) {
218 $this->commentFormatter
219 ->format( $current->getComment()->text )
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(
'',
'' );
286 private function enableTransactionalTimelimit() {
289 if ( !$this->getRequest()->wasPosted() ) {
295 $trxLimits = $this->context->getConfig()->get( MainConfigNames::TrxProfilerLimits );
297 $trxProfiler->redefineExpectations( $trxLimits[
'POST'], $fname );
298 DeferredUpdates::addCallableUpdate(
static function () use ( $trxProfiler, $trxLimits, $fname
300 $trxProfiler->redefineExpectations( $trxLimits[
'PostSend-POST'], $fname );
305 private function showRollbackConfirmationForm() {
307 if ( $form->show() ) {
317 'default' => $this->
msg(
'confirm-rollback-bottom' )->parse()
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.
getWikiPage()
Get a WikiPage object.
checkCanExecute(User $user)
Checks if the given user (identified by an object) can perform this action.
getContext()
Get the IContextSource in use here.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User being used for this instance.
setHeaders()
Set output headers for noindexing etc.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getAuthority()
Shortcut to get the Authority executing this instance.
getRequest()
Get the WebRequest being used for this instance.
Legacy class representing an editable page and handling UI for some page actions.
An error page that emits an HTTP 400 Bad Request status code.
An error page which can definitely be safely rendered using the OutputPage.
A class containing constants representing the names of configuration variables.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
User interface for the rollback action.
getFormFields()
Get an HTMLForm descriptor array.
__construct(Article $article, IContextSource $context, IContentHandlerFactory $contentHandlerFactory, RollbackPageFactory $rollbackPageFactory, UserOptionsLookup $userOptionsLookup, WatchlistManager $watchlistManager, CommentFormatter $commentFormatter)
getDescription()
Returns the description that goes below the <h1> element.
usesOOUI()
Whether the form should use OOUI.
onSubmit( $data)
Process the form on POST submission.
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
getRestriction()
Get the permission required to perform this action.
onSuccess()
Do something exciting on successful processing of the form.
getName()
Return the name of the action this object responds to.
Show an error when the user hits a rate limit.
Interface for objects which can provide a MediaWiki context on request.
Service for page rollback actions.