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' );
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 );
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 = Html::rawElement(
287 'div', [
'class' =>
'previewnote' ],
289 'h2', [
'id' =>
'mw-previewheader' ],
290 $this->context->msg(
'preview' )->text()
292 $out->parseAsInterface( $note ) .
296 $pageViewLang = $this->
getTitle()->getPageViewLanguage();
297 $attribs = [
'lang' => $pageViewLang->getHtmlCode(),
'dir' => $pageViewLang->getDir(),
298 'class' =>
'mw-content-' . $pageViewLang->getDir() ];
299 $previewHTML = Html::rawElement(
'div',
$attribs, $previewHTML );
301 $out->addHTML( $previewhead . $previewHTML );
307 if ( !$this->
getRequest()->getCheck(
'wpSave' ) ) {
312 $updater = $this->
page->getPage()->newPageUpdater( $this->context->getUser() );
319 return Status::newFatal(
'mcrundo-changed' );
327 foreach (
$newRev->getSlots()->getSlots()
as $slot ) {
331 if ( !
$newRev->hasSlot( $role ) ) {
336 $updater->setOriginalRevisionId(
false );
340 if ( $wgUseRCPatrol && $this->
getTitle()->userCan(
'autopatrol', $this->
getUser() ) ) {
341 $updater->setRcPatrolStatus( RecentChange::PRC_AUTOPATROLLED );
345 CommentStoreComment::newUnsavedComment( trim( $this->
getRequest()->getVal(
'wpSummary' ) ) ),
352 return Status::newGood();
364 'vertical-label' =>
true,
366 'default' =>
function () {
373 'name' =>
'wpSummary',
374 'cssclass' =>
'mw-summary',
375 'label-message' =>
'summary',
376 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
377 'value' =>
$request->getVal(
'wpSummary',
'' ),
379 'spellcheck' =>
'true',
381 'summarypreview' => [
383 'label-message' =>
'summary-preview',
388 if (
$request->getCheck(
'wpSummary' ) ) {
389 $ret[
'summarypreview'][
'default'] = Xml::tags(
'div', [
'class' =>
'mw-summary-preview' ],
393 unset(
$ret[
'summarypreview'] );
402 $labelAsPublish = $this->context->getConfig()->get(
'EditSubmitButtonLabelPublish' );
404 $form->
setId(
'mw-mcrundo-form' );
407 $form->
setSubmitTextMsg( $labelAsPublish ?
'publishchanges' :
'savechanges' );
411 'name' =>
'wpPreview',
413 'label-message' =>
'showpreview',
419 'label-message' =>
'showdiff',
437 return '<div style="clear:both"></div>';
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$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, $useParentheses=true)
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.
RevisionRecord null $curRev
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,...
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 & $ret
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
return true to allow those checks to and false if checking is done & $user
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
$page->newPageUpdater($user) $updater