50 parent::__construct( $article, $context );
94 if ( $from ===
null ) {
97 foreach ( [
'from',
'bot',
'hidediff',
'summary',
'token' ] as $param ) {
99 if ( $val !==
null ) {
115 if ( !$this->userOptionsLookup->getOption( $this->getUser(),
'showrollbackconfirmation' ) ||
116 $this->getRequest()->wasPosted()
120 $this->showRollbackConfirmationForm();
125 $this->enableTransactionalTimelimit();
126 $this->
getOutput()->addModuleStyles(
'mediawiki.interface.helpers.styles' );
132 if ( $from ===
null ) {
133 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingparam' );
136 throw new ErrorPageError(
'rollbackfailed',
'rollback-missingrevision' );
139 $revUser = $rev->getUser();
140 $userText = $revUser ? $revUser->getName() :
'';
141 if ( $from !== $userText ) {
143 $this->
getTitle()->getPrefixedText(),
149 if ( !$user->matchEditToken(
$request->getVal(
'token' ),
'rollback' ) ) {
150 throw new ErrorPageError(
'sessionfailure-title',
'sessionfailure' );
157 if ( $this->
getAuthority()->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
158 $revUser = $rev->getUser( RevisionRecord::RAW );
160 $revUser = $this->userFactory->newFromName( $this->context->msg(
'rev-deleted-user' )->plain() );
164 $rollbackResult = $this->rollbackPageFactory
167 ->setSummary(
$request->getText(
'summary' ) )
168 ->markAsBot(
$request->getBool(
'bot' ) )
169 ->rollbackIfAllowed();
170 $data = $rollbackResult->getValue();
172 if ( $rollbackResult->hasMessage(
'actionthrottledtext' ) ) {
176 # NOTE: Permission errors already handled by Action::checkExecute.
177 if ( $rollbackResult->hasMessage(
'readonlytext' ) ) {
181 if ( $rollbackResult->getMessages() ) {
182 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'rollbackfailed' ) );
184 foreach ( $rollbackResult->getMessages() as $msg ) {
189 ( $rollbackResult->hasMessage(
'alreadyrolled' ) ||
190 $rollbackResult->hasMessage(
'cantrollback' ) ||
191 $rollbackResult->hasMessage(
'rollback-nochange' ) )
192 && isset( $data[
'current-revision-record'] )
195 $current = $data[
'current-revision-record'];
196 $comment = $current->getComment()?->text;
198 if ( $comment !==
null && $comment !==
'' ) {
202 $this->commentFormatter
213 $current = $data[
'current-revision-record'];
214 $target = $data[
'target-revision-record'];
215 $newId = $data[
'newid'];
216 $this->
getOutput()->setPageTitleMsg( $this->
msg(
'actioncomplete' ) );
217 $this->
getOutput()->setRobotPolicy(
'noindex,nofollow' );
219 $old = Linker::revUserTools( $current );
220 $new = Linker::revUserTools( $target );
222 $currentUser = $current->getUser( RevisionRecord::FOR_THIS_USER, $user );
223 $targetUser = $target->getUser( RevisionRecord::FOR_THIS_USER, $user );
224 $userOptionsLookup = $this->userOptionsLookup;
226 $this->
msg(
'rollback-success' )
227 ->rawParams( $old, $new )
228 ->params( $currentUser ? $currentUser->getName() :
'' )
229 ->params( $targetUser ? $targetUser->getName() :
'' )
234 $this->
getOutput()->addModules(
'mediawiki.misc-authed-curate' );
238 'wgRollbackSuccess' =>
true,
241 'wgPostEditConfirmationDisabled' =>
true,
245 if ( $userOptionsLookup->
getBoolOption( $user,
'watchrollback' ) &&
246 !$this->watchlistManager->isWatchedIgnoringRights( $user, $this->getTitle() )
248 $this->watchlistManager->addWatchIgnoringRights( $user, $this->
getTitle(),
249 $userOptionsLookup->
getOption( $user,
'watchrollback-expiry' ) );
254 if ( !
$request->getBool(
'hidediff',
false ) &&
255 !$userOptionsLookup->
getBoolOption( $this->getUser(),
'norollbackdiff' )
257 $contentModel = $current->getMainContentModel();
258 $contentHandler = $this->contentHandlerFactory->getContentHandler( $contentModel );
259 $de = $contentHandler->createDifferenceEngine(
266 $de->showDiff(
'',
'' );
274 private function enableTransactionalTimelimit() {
284 $trxProfiler = Profiler::instance()->getTransactionProfiler();
285 $trxProfiler->redefineExpectations( $trxLimits[
'POST'], $fname );
288 $trxProfiler->redefineExpectations( $trxLimits[
'PostSend-POST'], $fname );
293 private function showRollbackConfirmationForm() {
295 if ( $form->show() ) {
306 'default' => $this->
msg(
'confirm-rollback-bottom' )->parse()
313class_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.
Interface for objects which can provide a MediaWiki context on request.
Service for page rollback actions.