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;
118 $from = $this->
getRequest()->getVal(
'from' );
119 if ( $from ===
null ) {
120 throw new BadRequestError(
'rollbackfailed',
'rollback-missingparam' );
122 foreach ( [
'from',
'bot',
'hidediff',
'summary',
'token' ] as $param ) {
124 if ( $val !==
null ) {
140 if ( !$this->userOptionsLookup->getOption( $this->getUser(),
'showrollbackconfirmation' ) ||
141 $this->getRequest()->wasPosted()
145 $this->showRollbackConfirmationForm();
150 $this->enableTransactionalTimelimit();
151 $this->
getOutput()->addModuleStyles(
'mediawiki.interface.helpers.styles' );
155 $from = $request->getVal(
'from' );
157 if ( $from ===
null ) {
158 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingparam' );
161 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingrevision' );
164 $revUser = $rev->getUser();
165 $userText = $revUser ? $revUser->getName() :
'';
166 if ( $from !== $userText ) {
168 $this->
getTitle()->getPrefixedText(),
174 if ( !$user->matchEditToken( $request->getVal(
'token' ),
'rollback' ) ) {
175 throw new ErrorPageError(
'sessionfailure-title',
'sessionfailure' );
182 if ( $this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
183 $revUser = $rev->getUser( RevisionRecord::RAW );
186 $revUser = $userFactory->newFromName( $this->context->msg(
'rev-deleted-user' )->plain() );
190 $rollbackResult = $this->rollbackPageFactory
193 ->setSummary( $request->getText(
'summary' ) )
194 ->markAsBot( $request->getBool(
'bot' ) )
195 ->rollbackIfAllowed();
196 $data = $rollbackResult->getValue();
198 if ( $rollbackResult->hasMessage(
'actionthrottledtext' ) ) {
202 # NOTE: Permission errors already handled by Action::checkExecute.
203 if ( $rollbackResult->hasMessage(
'readonlytext' ) ) {
207 if ( $rollbackResult->getMessages() ) {
208 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'rollbackfailed' ) );
210 foreach ( $rollbackResult->getMessages() as $msg ) {
215 ( $rollbackResult->hasMessage(
'alreadyrolled' ) || $rollbackResult->hasMessage(
'cantrollback' ) )
216 && isset( $data[
'current-revision-record'] )
219 $current = $data[
'current-revision-record'];
221 if ( $current->getComment() !=
null ) {
225 $this->commentFormatter
226 ->format( $current->getComment()->text )
236 $current = $data[
'current-revision-record'];
237 $target = $data[
'target-revision-record'];
238 $newId = $data[
'newid'];
239 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'actioncomplete' ) );
240 $this->
getOutput()->setRobotPolicy(
'noindex,nofollow' );
242 $old = Linker::revUserTools( $current );
243 $new = Linker::revUserTools( $target );
245 $currentUser = $current->getUser( RevisionRecord::FOR_THIS_USER, $user );
246 $targetUser = $target->getUser( RevisionRecord::FOR_THIS_USER, $user );
248 $this->
msg(
'rollback-success' )
249 ->rawParams( $old, $new )
250 ->params( $currentUser ? $currentUser->getName() :
'' )
251 ->params( $targetUser ? $targetUser->getName() :
'' )
256 $this->
getOutput()->addModules(
'mediawiki.misc-authed-curate' );
260 'wgRollbackSuccess' =>
true,
263 'wgPostEditConfirmationDisabled' =>
true,
266 if ( $this->userOptionsLookup->getBoolOption( $user,
'watchrollback' ) ) {
267 $this->watchlistManager->addWatchIgnoringRights( $user, $this->
getTitle() );
272 if ( !$request->getBool(
'hidediff',
false ) &&
273 !$this->userOptionsLookup->getBoolOption( $this->getUser(),
'norollbackdiff' )
275 $contentModel = $current->getMainContentModel();
276 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
277 $de = $contentHandler->createDifferenceEngine(
284 $de->showDiff(
'',
'' );
292 private function enableTransactionalTimelimit() {
303 $trxProfiler->redefineExpectations( $trxLimits[
'POST'], $fname );
306 $trxProfiler->redefineExpectations( $trxLimits[
'PostSend-POST'], $fname );
311 private function showRollbackConfirmationForm() {
313 if ( $form->show() ) {
323 'default' => $this->
msg(
'confirm-rollback-bottom' )->parse()
330class_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.