47 MediaWiki\Session\SessionManager::getGlobalSession()->persist();
53 $out->setRobotPolicy(
'noindex,nofollow' );
54 if ( $this->
getContext()->getConfig()->
get(
'UseMediaWikiUIEverywhere' ) ) {
55 $out->addModuleStyles( [
57 'mediawiki.ui.checkbox',
65 "<div id=\"mw-read-only-warning\">\n$1\n</div>",
68 } elseif ( $this->context->getUser()->isAnon() ) {
69 if ( !$this->
getRequest()->getCheck(
'wpPreview' ) ) {
71 "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
74 SpecialPage::getTitleFor(
'Userlogin' )->getFullURL( [
75 'returnto' => $this->
getTitle()->getPrefixedDBkey()
78 SpecialPage::getTitleFor(
'CreateAccount' )->getFullURL( [
79 'returnto' => $this->
getTitle()->getPrefixedDBkey()
84 $out->wrapWikiMsg(
"<div id=\"mw-anon-preview-warning\" class=\"warningbox\">\n$1</div>",
94 $this->undoafter = $this->
getRequest()->getInt(
'undoafter' );
97 if ( $this->
undo == 0 || $this->undoafter == 0 ) {
98 throw new ErrorPageError(
'mcrundofailed',
'mcrundo-missingparam' );
101 $curRev = $this->page->getRevision();
105 $this->curRev =
$curRev->getRevisionRecord();
106 $this->cur = $this->
getRequest()->getInt(
'cur', $this->curRev->getId() );
110 parent::checkCanExecute( $user );
114 $revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
116 $undoRev = $revisionLookup->getRevisionById( $this->
undo );
117 $oldRev = $revisionLookup->getRevisionById( $this->undoafter );
119 if ( $undoRev ===
null || $oldRev ===
null ||
120 $undoRev->isDeleted( RevisionRecord::DELETED_TEXT ) ||
121 $oldRev->isDeleted( RevisionRecord::DELETED_TEXT )
133 $revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
135 $undoRev = $revisionLookup->getRevisionById( $this->
undo );
136 $oldRev = $revisionLookup->getRevisionById( $this->undoafter );
139 $isLatest =
$curRev->getId() === $undoRev->getId();
141 if ( $undoRev ===
null || $oldRev ===
null ||
142 $undoRev->isDeleted( RevisionRecord::DELETED_TEXT ) ||
143 $oldRev->isDeleted( RevisionRecord::DELETED_TEXT )
150 return MutableRevisionRecord::newFromParentRevision( $oldRev );
153 $newRev = MutableRevisionRecord::newFromParentRevision(
$curRev );
157 $rolesToMerge = array_unique( array_merge(
158 $oldRev->getSlotRoles(),
159 $undoRev->getSlotRoles(),
165 $rolesToMerge = array_intersect(
166 $rolesToMerge, $oldRev->getSlots()->getRolesWithDifferentContent( $undoRev->getSlots() )
168 if ( !$rolesToMerge ) {
174 $rolesToMerge = array_intersect(
175 $rolesToMerge, $oldRev->getSlots()->getRolesWithDifferentContent(
$curRev->getSlots() )
177 if ( !$rolesToMerge ) {
183 $diffRoles = array_intersect(
184 $rolesToMerge, $undoRev->getSlots()->getRolesWithDifferentContent(
$curRev->getSlots() )
186 foreach ( array_diff( $rolesToMerge, $diffRoles ) as $role ) {
187 if ( $oldRev->hasSlot( $role ) ) {
188 $newRev->inheritSlot( $oldRev->getSlot( $role, RevisionRecord::RAW ) );
193 $rolesToMerge = $diffRoles;
204 foreach ( $rolesToMerge as $role ) {
205 if ( !$oldRev->hasSlot( $role ) || !$undoRev->hasSlot( $role ) || !
$curRev->hasSlot( $role ) ) {
211 foreach ( $rolesToMerge as $role ) {
212 $oldContent = $oldRev->getSlot( $role, RevisionRecord::RAW )->getContent();
213 $undoContent = $undoRev->getSlot( $role, RevisionRecord::RAW )->getContent();
214 $curContent =
$curRev->getSlot( $role, RevisionRecord::RAW )->getContent();
215 $newContent = $undoContent->getContentHandler()
216 ->getUndoContent( $curContent, $undoContent, $oldContent, $isLatest );
217 if ( !$newContent ) {
220 $newRev->setSlot( SlotRecord::newUnsaved( $role, $newContent ) );
228 if (
$newRev->hasSameContent( $this->curRev ) ) {
233 $diffEngine->setRevisions( $this->curRev,
$newRev );
235 $oldtitle = $this->context->msg(
'currentrev' )->parse();
236 $newtitle = $this->context->msg(
'yourtext' )->parse();
238 if ( $this->
getRequest()->getCheck(
'wpPreview' ) ) {
242 $diffText = $diffEngine->getDiff( $oldtitle, $newtitle );
243 $diffEngine->showDiffStyle();
244 return '<div id="wikiDiff">' . $diffText .
'</div>';
255 # provide a anchor link to the form
256 $continueEditing =
'<span class="mw-continue-editing">' .
257 '[[#mw-mcrundo-form|' .
258 $this->context->getLanguage()->getArrow() .
' ' .
259 $this->context->msg(
'continue-editing' )->text() .
']]</span>';
261 $note = $this->context->msg(
'previewnote' )->plain() .
' ' . $continueEditing;
263 $parserOptions = $this->page->makeParserOptions( $this->context );
264 $parserOptions->setIsPreview(
true );
265 $parserOptions->setIsSectionPreview(
false );
266 $parserOptions->enableLimitReport();
268 $parserOutput = MediaWikiServices::getInstance()->getRevisionRenderer()
269 ->getRenderedRevision(
$rev, $parserOptions, $this->context->getUser() )
270 ->getRevisionParserOutput();
271 $previewHTML = $parserOutput->getText( [
'enableSectionEditLinks' =>
false ] );
273 $out->addParserOutputMetadata( $parserOutput );
274 if ( count( $parserOutput->getWarnings() ) ) {
275 $note .=
"\n\n" . implode(
"\n\n", $parserOutput->getWarnings() );
278 $m = $this->context->msg(
279 'content-failed-to-parse',
282 $note .=
"\n\n" . $m->parse();
286 $previewhead =
"<div class='previewnote'>\n" .
287 '<h2 id="mw-previewheader">' . $this->context->msg(
'preview' )->escaped() .
"</h2>" .
288 $out->parse( $note,
true,
true ) .
"<hr /></div>\n";
290 $pageViewLang = $this->
getTitle()->getPageViewLanguage();
291 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
292 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
293 $previewHTML = Html::rawElement(
'div',
$attribs, $previewHTML );
295 $out->addHtml( $previewhead . $previewHTML );
301 if ( !$this->
getRequest()->getCheck(
'wpSave' ) ) {
306 $updater = $this->page->getPage()->newPageUpdater( $this->context->getUser() );
312 if ( $this->cur !==
$curRev->getId() ) {
313 return Status::newFatal(
'mcrundo-changed' );
321 foreach (
$newRev->getSlots()->getSlots() as $slot ) {
324 foreach (
$curRev->getSlotRoles() as $role ) {
325 if ( !
$newRev->hasSlot( $role ) ) {
330 $updater->setOriginalRevisionId(
false );
334 if ( $wgUseRCPatrol && $this->
getTitle()->userCan(
'autopatrol', $this->
getUser() ) ) {
335 $updater->setRcPatrolStatus( RecentChange::PRC_AUTOPATROLLED );
339 CommentStoreComment::newUnsavedComment( trim( $this->
getRequest()->getVal(
'wpSummary' ) ) ),
346 return Status::newGood();
355 $config = $this->context->getConfig();
356 $oldCommentSchema = $config->get(
'CommentTableSchemaMigrationStage' ) ===
MIGRATION_OLD;
360 'vertical-label' =>
true,
362 'default' =>
function () {
369 'name' =>
'wpSummary',
370 'cssclass' =>
'mw-summary',
371 'label-message' =>
'summary',
372 'maxlength' => $oldCommentSchema ? 200 : CommentStore::COMMENT_CHARACTER_LIMIT,
373 'value' =>
$request->getVal(
'wpSummary',
'' ),
375 'spellcheck' =>
'true',
377 'summarypreview' => [
379 'label-message' =>
'summary-preview',
384 if (
$request->getCheck(
'wpSummary' ) ) {
385 $ret[
'summarypreview'][
'default'] = Xml::tags(
'div', [
'class' =>
'mw-summary-preview' ],
389 unset(
$ret[
'summarypreview'] );
396 $form->setWrapperLegendMsg(
'confirm-mcrundo-title' );
398 $labelAsPublish = $this->context->getConfig()->get(
'EditSubmitButtonLabelPublish' );
400 $form->setId(
'mw-mcrundo-form' );
401 $form->setSubmitName(
'wpSave' );
402 $form->setSubmitTooltip( $labelAsPublish ?
'publish' :
'save' );
403 $form->setSubmitTextMsg( $labelAsPublish ?
'publishchanges' :
'savechanges' );
404 $form->showCancel(
true );
405 $form->setCancelTarget( $this->
getTitle() );
407 'name' =>
'wpPreview',
409 'label-message' =>
'showpreview',
415 'label-message' =>
'showdiff',
423 $form->addHiddenField(
'undo', $this->
undo );
425 $form->addHiddenField(
'cur', $this->curRev->getId() );
433 return '<div style="clear:both"></div>';
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
wfReadOnly()
Check whether the wiki is in read-only mode.
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
getTitle()
Shortcut to get the Title object from the page.
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.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getRequest()
Get the WebRequest being used for this instance.
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
An error page which can definitely be safely rendered using the OutputPage.
static commentBlock( $comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
Exception representing a failure to serialize or unserialize a content object.
Temporary action for MCR undos.
show()
The basic pattern for actions is to display some sort of HTMLForm UI, maybe with some stuff underneat...
onSuccess()
Do something exciting on successful processing of the form.
showPreview(RevisionRecord $rev)
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
checkCanExecute(User $user)
Checks if the given user (identified by an object) can perform this action.
onSubmit( $data)
Process the form on POST submission.
getDescription()
Returns the description that goes below the <h1> tag.
preText()
Add pre- or post-text to the form.
addStatePropagationFields(HTMLForm $form)
getName()
Return the name of the action this object responds to.
usesOOUI()
Whether the form should use OOUI.
getFormFields()
Get an HTMLForm descriptor array.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
presenting them properly to the user as errors is done by the caller return true use this to change the list i e undo
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
$page->newPageUpdater($user) $updater