', true, /* interface */true );
}
@@ -1432,7 +1424,7 @@ class EditPage {
/**
* Make sure the form isn't faking a user's credentials.
*
- * @param WebRequest $request
+ * @param WebRequest &$request
* @return bool
* @private
*/
@@ -1475,7 +1467,7 @@ class EditPage {
/**
* Attempt submission
- * @param array|bool $resultDetails See docs for $result in internalAttemptSave
+ * @param array|bool &$resultDetails See docs for $result in internalAttemptSave
* @throws UserBlockedError|ReadOnlyError|ThrottledError|PermissionsError
* @return Status The resulting status object.
*/
@@ -1515,7 +1507,7 @@ class EditPage {
* @return bool False, if output is done, true if rest of the form should be displayed
*/
private function handleStatus( Status $status, $resultDetails ) {
- global $wgUser, $wgOut;
+ global $wgUser;
/**
* @todo FIXME: once the interface for internalAttemptSave() is made
@@ -1532,6 +1524,8 @@ class EditPage {
}
}
+ $out = $this->context->getOutput();
+
// "wpExtraQueryRedirect" is a hidden input to modify
// after save URL and is not used by actual edit form
$request = RequestContext::getMain()->getRequest();
@@ -1555,7 +1549,7 @@ class EditPage {
case self::AS_CANNOT_USE_CUSTOM_MODEL:
case self::AS_PARSE_ERROR:
- $wgOut->addWikiText( '
' . "\n" . $status->getWikiText() . '
' );
+ $out->addWikiText( '
' . "\n" . $status->getWikiText() . '
' );
return true;
case self::AS_SUCCESS_NEW_ARTICLE:
@@ -1568,7 +1562,7 @@ class EditPage {
}
}
$anchor = isset( $resultDetails['sectionanchor'] ) ? $resultDetails['sectionanchor'] : '';
- $wgOut->redirect( $this->mTitle->getFullURL( $query ) . $anchor );
+ $out->redirect( $this->mTitle->getFullURL( $query ) . $anchor );
return false;
case self::AS_SUCCESS_UPDATE:
@@ -1596,7 +1590,7 @@ class EditPage {
}
}
- $wgOut->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
+ $out->redirect( $this->mTitle->getFullURL( $extraQuery ) . $sectionanchor );
return false;
case self::AS_SPAM_ERROR:
@@ -1721,12 +1715,12 @@ class EditPage {
/**
* Attempt submission (no UI)
*
- * @param array $result Array to add statuses to, currently with the
+ * @param array &$result Array to add statuses to, currently with the
* possible keys:
* - spam (string): Spam string from content if any spam is detected by
* matchSpamRegex.
* - sectionanchor (string): Section anchor for a section save.
- * - nullEdit (boolean): Set if doEditContent is OK. True if null edit,
+ * - nullEdit (bool): Set if doEditContent is OK. True if null edit,
* false otherwise.
* - redirect (bool): Set if doEditContent is OK. True if resulting
* revision is a redirect.
@@ -2351,29 +2345,31 @@ class EditPage {
}
public function setHeaders() {
- global $wgOut, $wgUser, $wgAjaxEditStash;
+ global $wgUser, $wgAjaxEditStash;
+
+ $out = $this->context->getOutput();
- $wgOut->addModules( 'mediawiki.action.edit' );
- $wgOut->addModuleStyles( 'mediawiki.action.edit.styles' );
+ $out->addModules( 'mediawiki.action.edit' );
+ $out->addModuleStyles( 'mediawiki.action.edit.styles' );
if ( $wgUser->getOption( 'showtoolbar' ) ) {
// The addition of default buttons is handled by getEditToolbar() which
// has its own dependency on this module. The call here ensures the module
// is loaded in time (it has position "top") for other modules to register
// buttons (e.g. extensions, gadgets, user scripts).
- $wgOut->addModules( 'mediawiki.toolbar' );
+ $out->addModules( 'mediawiki.toolbar' );
}
if ( $wgUser->getOption( 'uselivepreview' ) ) {
- $wgOut->addModules( 'mediawiki.action.edit.preview' );
+ $out->addModules( 'mediawiki.action.edit.preview' );
}
if ( $wgUser->getOption( 'useeditwarning' ) ) {
- $wgOut->addModules( 'mediawiki.action.edit.editWarning' );
+ $out->addModules( 'mediawiki.action.edit.editWarning' );
}
# Enabled article-related sidebar, toplinks, etc.
- $wgOut->setArticleRelated( true );
+ $out->setArticleRelated( true );
$contextTitle = $this->getContextTitle();
if ( $this->isConflict ) {
@@ -2396,10 +2392,10 @@ class EditPage {
if ( $displayTitle === false ) {
$displayTitle = $contextTitle->getPrefixedText();
}
- $wgOut->setPageTitle( $this->context->msg( $msg, $displayTitle ) );
+ $out->setPageTitle( $this->context->msg( $msg, $displayTitle ) );
# Transmit the name of the message to JavaScript for live preview
# Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys
- $wgOut->addJsConfigVars( [
+ $out->addJsConfigVars( [
'wgEditMessage' => $msg,
'wgAjaxEditStash' => $wgAjaxEditStash,
] );
@@ -2409,16 +2405,17 @@ class EditPage {
* Show all applicable editing introductions
*/
protected function showIntro() {
- global $wgOut, $wgUser;
+ global $wgUser;
if ( $this->suppressIntro ) {
return;
}
+ $out = $this->context->getOutput();
$namespace = $this->mTitle->getNamespace();
if ( $namespace == NS_MEDIAWIKI ) {
# Show a warning if editing an interface message
- $wgOut->wrapWikiMsg( "
\n$1\n
", 'editinginterface' );
+ $out->wrapWikiMsg( "
\n$1\n
", 'editinginterface' );
# If this is a default message (but not css or js),
# show a hint that it is translatable on translatewiki.net
if ( !$this->mTitle->hasContentModel( CONTENT_MODEL_CSS )
@@ -2426,7 +2423,7 @@ class EditPage {
) {
$defaultMessageText = $this->mTitle->getDefaultMessageText();
if ( $defaultMessageText !== false ) {
- $wgOut->wrapWikiMsg( "
\n$1\n
",
+ $out->wrapWikiMsg( "
\n$1\n
",
'translateinterface' );
}
}
@@ -2438,11 +2435,11 @@ class EditPage {
# there must be a description url to show a hint to shared repo
if ( $descUrl ) {
if ( !$this->mTitle->exists() ) {
- $wgOut->wrapWikiMsg( "
", [
'sharedupload-desc-edit', $file->getRepo()->getDisplayName(), $descUrl
] );
}
@@ -2458,12 +2455,12 @@ class EditPage {
$ip = User::isIP( $username );
$block = Block::newFromTarget( $user, $user );
if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
- $wgOut->wrapWikiMsg( "
\n$1\n
",
+ $out->wrapWikiMsg( "
\n$1\n
",
[ 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ] );
} elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
# Show log extract if the user is currently blocked
LogEventsList::showLogExtract(
- $wgOut,
+ $out,
'block',
MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
'',
@@ -2484,7 +2481,7 @@ class EditPage {
$this->context->msg( 'helppage' )->inContentLanguage()->text()
) );
if ( $wgUser->isLoggedIn() ) {
- $wgOut->wrapWikiMsg(
+ $out->wrapWikiMsg(
// Suppress the external link icon, consider the help url an internal one
"
\n$1\n
",
[
@@ -2493,7 +2490,7 @@ class EditPage {
]
);
} else {
- $wgOut->wrapWikiMsg(
+ $out->wrapWikiMsg(
// Suppress the external link icon, consider the help url an internal one
"
\n$1\n
",
[
@@ -2507,7 +2504,7 @@ class EditPage {
if ( !$this->mTitle->exists() ) {
$dbr = wfGetDB( DB_REPLICA );
- LogEventsList::showLogExtract( $wgOut, [ 'delete', 'move' ], $this->mTitle,
+ LogEventsList::showLogExtract( $out, [ 'delete', 'move' ], $this->mTitle,
'',
[
'lim' => 10,
@@ -2528,9 +2525,8 @@ class EditPage {
if ( $this->editintro ) {
$title = Title::newFromText( $this->editintro );
if ( $title instanceof Title && $title->exists() && $title->userCan( 'read' ) ) {
- global $wgOut;
// Added using template syntax, to take 's into account.
- $wgOut->addWikiTextTitleTidy(
+ $this->context->getOutput()->addWikiTextTitleTidy(
'
{{:' . $title->getFullText() . '}}
',
$this->mTitle
);
@@ -2602,7 +2598,7 @@ class EditPage {
}
/**
- * Send the edit form and related headers to $wgOut
+ * Send the edit form and related headers to OutputPage
* @param callable|null $formCallback That takes an OutputPage parameter; will be called
* during form output near the top, for captchas and the like.
*
@@ -2610,7 +2606,7 @@ class EditPage {
* use the EditPage::showEditForm:fields hook instead.
*/
public function showEditForm( $formCallback = null ) {
- global $wgOut, $wgUser;
+ global $wgUser;
# need to parse the preview early so that we know which templates are used,
# otherwise users with "show preview after edit box" will get a blank list
@@ -2621,9 +2617,11 @@ class EditPage {
$previewOutput = $this->getPreviewText();
}
+ $out = $this->context->getOutput();
+
// Avoid PHP 7.1 warning of passing $this by reference
$editPage = $this;
- Hooks::run( 'EditPage::showEditForm:initial', [ &$editPage, &$wgOut ] );
+ Hooks::run( 'EditPage::showEditForm:initial', [ &$editPage, &$out ] );
$this->setHeaders();
@@ -2636,19 +2634,19 @@ class EditPage {
// We use $this->section to much before this and getVal('wgSection') directly in other places
// at this point we can't reset $this->section to '' to fallback to non-section editing.
// Someone is welcome to try refactoring though
- $wgOut->showErrorPage( 'sectioneditnotsupported-title', 'sectioneditnotsupported-text' );
+ $out->showErrorPage( 'sectioneditnotsupported-title', 'sectioneditnotsupported-text' );
return;
}
$this->showHeader();
- $wgOut->addHTML( $this->editFormPageTop );
+ $out->addHTML( $this->editFormPageTop );
if ( $wgUser->getOption( 'previewontop' ) ) {
$this->displayPreviewArea( $previewOutput, true );
}
- $wgOut->addHTML( $this->editFormTextTop );
+ $out->addHTML( $this->editFormTextTop );
$showToolbar = true;
if ( $this->wasDeletedSinceLastEdit() ) {
@@ -2657,17 +2655,17 @@ class EditPage {
// Add an confirmation checkbox and explanation.
$showToolbar = false;
} else {
- $wgOut->wrapWikiMsg( "
\n$1\n
",
+ $out->wrapWikiMsg( "
\n$1\n
",
'deletedwhileediting' );
}
}
// @todo add EditForm plugin interface and use it here!
// search for textarea1 and textarea2, and allow EditForm to override all uses.
- $wgOut->addHTML( Html::openElement(
+ $out->addHTML( Html::openElement(
'form',
[
- 'class' => $this->oouiEnabled ? 'mw-editform-ooui' : 'mw-editform-legacy',
+ 'class' => 'mw-editform',
'id' => self::EDITFORM_ID,
'name' => self::EDITFORM_ID,
'method' => 'post',
@@ -2678,11 +2676,11 @@ class EditPage {
if ( is_callable( $formCallback ) ) {
wfWarn( 'The $formCallback parameter to ' . __METHOD__ . 'is deprecated' );
- call_user_func_array( $formCallback, [ &$wgOut ] );
+ call_user_func_array( $formCallback, [ &$out ] );
}
// Add an empty field to trip up spambots
- $wgOut->addHTML(
+ $out->addHTML(
Xml::openElement( 'div', [ 'id' => 'antispam-container', 'style' => 'display: none;' ] )
. Html::rawElement(
'label',
@@ -2703,21 +2701,21 @@ class EditPage {
// Avoid PHP 7.1 warning of passing $this by reference
$editPage = $this;
- Hooks::run( 'EditPage::showEditForm:fields', [ &$editPage, &$wgOut ] );
+ Hooks::run( 'EditPage::showEditForm:fields', [ &$editPage, &$out ] );
// Put these up at the top to ensure they aren't lost on early form submission
$this->showFormBeforeText();
if ( $this->wasDeletedSinceLastEdit() && 'save' == $this->formtype ) {
$username = $this->lastDelete->user_name;
- $comment = $this->lastDelete->log_comment;
+ $comment = CommentStore::newKey( 'log_comment' )->getComment( $this->lastDelete )->text;
// It is better to not parse the comment at all than to have templates expanded in the middle
// TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
$key = $comment === ''
? 'confirmrecreate-noreason'
: 'confirmrecreate';
- $wgOut->addHTML(
+ $out->addHTML(
'
' );
}
}
}
/**
- * Append preview output to $wgOut.
+ * Append preview output to OutputPage.
* Includes category rendering if this is a category page.
*
* @param string $text The HTML to be output for the preview.
*/
protected function showPreview( $text ) {
- global $wgOut;
if ( $this->mArticle instanceof CategoryPage ) {
$this->mArticle->openShowCategory();
}
# This hook seems slightly odd here, but makes things more
# consistent for extensions.
- Hooks::run( 'OutputPageBeforeHTML', [ &$wgOut, &$text ] );
- $wgOut->addHTML( $text );
+ $out = $this->context->getOutput();
+ Hooks::run( 'OutputPageBeforeHTML', [ &$out, &$text ] );
+ $out->addHTML( $text );
if ( $this->mArticle instanceof CategoryPage ) {
$this->mArticle->closeShowCategory();
}
@@ -3405,7 +3403,7 @@ class EditPage {
* save and then make a comparison.
*/
public function showDiff() {
- global $wgUser, $wgContLang, $wgOut;
+ global $wgUser, $wgContLang;
$oldtitlemsg = 'currentrev';
# if message does not exist, show diff against the preloaded default
@@ -3460,7 +3458,7 @@ class EditPage {
$difftext = '';
}
- $wgOut->addHTML( '
' . $difftext . '
' );
+ $this->context->getOutput()->addHTML( '
' . $difftext . '
' );
}
/**
@@ -3469,8 +3467,7 @@ class EditPage {
protected function showHeaderCopyrightWarning() {
$msg = 'editpage-head-copy-warn';
if ( !$this->context->msg( $msg )->isDisabled() ) {
- global $wgOut;
- $wgOut->wrapWikiMsg( "
' );
}
}
@@ -3499,8 +3496,7 @@ class EditPage {
* characters not present on most keyboards for copying/pasting.
*/
protected function showEditTools() {
- global $wgOut;
- $wgOut->addHTML( '
\n" );
}
/**
@@ -3657,14 +3645,13 @@ class EditPage {
* If you want to use another entry point to this function, be careful.
*/
protected function showConflict() {
- global $wgOut;
-
+ $out = $this->context->getOutput();
// Avoid PHP 7.1 warning of passing $this by reference
$editPage = $this;
- if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$editPage, &$wgOut ] ) ) {
+ if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$editPage, &$out ] ) ) {
$this->incrementConflictStats();
- $wgOut->wrapWikiMsg( '