77 parent::__construct( $article,
$context );
78 $this->contentHandlerFactory = $contentHandlerFactory;
79 $this->rollbackPageFactory = $rollbackPageFactory;
80 $this->userOptionsLookup = $userOptionsLookup;
81 $this->watchlistManager = $watchlistManager;
82 $this->commentFormatter = $commentFormatter;
125 $from = $this->
getRequest()->getVal(
'from' );
126 if ( $from ===
null ) {
127 throw new BadRequestError(
'rollbackfailed',
'rollback-missingparam' );
129 foreach ( [
'from',
'bot',
'hidediff',
'summary',
'token' ] as $param ) {
131 if ( $val !==
null ) {
147 if ( !$this->userOptionsLookup->getOption( $this->getUser(),
'showrollbackconfirmation' ) ||
148 $this->getRequest()->wasPosted()
152 $this->showRollbackConfirmationForm();
157 $this->enableTransactionalTimelimit();
158 $this->
getOutput()->addModuleStyles(
'mediawiki.interface.helpers.styles' );
162 $from = $request->getVal(
'from' );
164 if ( $from ===
null ) {
165 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingparam' );
168 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingrevision' );
171 $revUser = $rev->getUser();
172 $userText = $revUser ? $revUser->getName() :
'';
173 if ( $from !== $userText ) {
175 $this->
getTitle()->getPrefixedText(),
181 if ( !$user->matchEditToken( $request->getVal(
'token' ),
'rollback' ) ) {
182 throw new ErrorPageError(
'sessionfailure-title',
'sessionfailure' );
189 if ( $this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
190 $revUser = $rev->getUser( RevisionRecord::RAW );
193 $revUser = $userFactory->newFromName( $this->context->msg(
'rev-deleted-user' )->plain() );
197 $rollbackResult = $this->rollbackPageFactory
200 ->setSummary( $request->getText(
'summary' ) )
201 ->markAsBot( $request->getBool(
'bot' ) )
202 ->rollbackIfAllowed();
203 $data = $rollbackResult->getValue();
205 if ( $rollbackResult->hasMessage(
'actionthrottledtext' ) ) {
209 # NOTE: Permission errors already handled by Action::checkExecute.
210 if ( $rollbackResult->hasMessage(
'readonlytext' ) ) {
214 if ( $rollbackResult->getMessages() ) {
215 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'rollbackfailed' ) );
217 foreach ( $rollbackResult->getMessages() as $msg ) {
222 ( $rollbackResult->hasMessage(
'alreadyrolled' ) || $rollbackResult->hasMessage(
'cantrollback' ) )
223 && isset( $data[
'current-revision-record'] )
226 $current = $data[
'current-revision-record'];
228 if ( $current->getComment() !=
null ) {
232 $this->commentFormatter
233 ->format( $current->getComment()->text )
243 $current = $data[
'current-revision-record'];
244 $target = $data[
'target-revision-record'];
245 $newId = $data[
'newid'];
246 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'actioncomplete' ) );
247 $this->
getOutput()->setRobotPolicy(
'noindex,nofollow' );
249 $old = Linker::revUserTools( $current );
250 $new = Linker::revUserTools( $target );
252 $currentUser = $current->getUser( RevisionRecord::FOR_THIS_USER, $user );
253 $targetUser = $target->getUser( RevisionRecord::FOR_THIS_USER, $user );
254 $userOptionsLookup = $this->userOptionsLookup;
256 $this->
msg(
'rollback-success' )
257 ->rawParams( $old, $new )
258 ->params( $currentUser ? $currentUser->getName() :
'' )
259 ->params( $targetUser ? $targetUser->getName() :
'' )
264 $this->
getOutput()->addModules(
'mediawiki.misc-authed-curate' );
268 'wgRollbackSuccess' =>
true,
271 'wgPostEditConfirmationDisabled' =>
true,
275 if ( $userOptionsLookup->
getBoolOption( $user,
'watchrollback' ) &&
276 !$this->watchlistManager->isWatchedIgnoringRights( $user, $this->getTitle() )
278 $this->watchlistManager->addWatchIgnoringRights( $user, $this->
getTitle(),
279 $userOptionsLookup->
getOption( $user,
'watchrollback-expiry' ) );
284 if ( !$request->getBool(
'hidediff',
false ) &&
285 !$userOptionsLookup->
getBoolOption( $this->getUser(),
'norollbackdiff' )
287 $contentModel = $current->getMainContentModel();
288 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
289 $de = $contentHandler->createDifferenceEngine(
296 $de->showDiff(
'',
'' );
304 private function enableTransactionalTimelimit() {
315 $trxProfiler->redefineExpectations( $trxLimits[
'POST'], $fname );
318 $trxProfiler->redefineExpectations( $trxLimits[
'PostSend-POST'], $fname );
323 private function showRollbackConfirmationForm() {
325 if ( $form->show() ) {
336 'default' => $this->
msg(
'confirm-rollback-bottom' )->parse()
343class_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.