mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 14:06:52 +00:00
ApiVisualEditor: Remove $wgTitle hack, set page for {{PAGENAME}}
when needed
Depends on core changes I242e042317 and I6e9356a6cc to set the context page for messages generated in Title::getEditNotices() and LogEventsList::showLogExtract() too. Set the context page for other messages whose overrides on Wikimedia wikis commonly depend on it, which I checked using Global Search, e.g. https://global-search.toolforge.org/?q=PAGENAME®ex=1&namespaces=8&title=Editingold Depends-On: I242e042317a1e16c8d51edbf7800c8b7d70d468e Depends-On: I6e9356a6cc3b9df9b508c3d37a0b9b75d6825efd Bug: T300184 Change-Id: I0746618b1f6da3e5fd213d8adad9b1f4ec2fe23b
This commit is contained in:
parent
839a62829d
commit
aed5bcf7d0
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset>
|
||||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
|
||||
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
|
||||
</rule>
|
||||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
|
||||
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma">
|
||||
<severity>5</severity>
|
||||
|
|
|
@ -161,12 +161,6 @@ class ApiVisualEditor extends ApiBase {
|
|||
case 'parse':
|
||||
case 'wikitext':
|
||||
case 'metadata':
|
||||
// Dirty hack to provide the correct context for edit notices
|
||||
// FIXME Don't write to globals! Eww.
|
||||
global $wgTitle;
|
||||
$wgTitle = $title;
|
||||
RequestContext::getMain()->setTitle( $title );
|
||||
|
||||
$preloaded = false;
|
||||
$restbaseHeaders = null;
|
||||
|
||||
|
@ -319,12 +313,12 @@ class ApiVisualEditor extends ApiBase {
|
|||
'{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',
|
||||
// Sign-up link
|
||||
'{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}'
|
||||
)->parseAsBlock();
|
||||
)->page( $title )->parseAsBlock();
|
||||
}
|
||||
|
||||
// Old revision notice
|
||||
if ( $restoring ) {
|
||||
$notices['editingold'] = $this->msg( 'editingold' )->parseAsBlock();
|
||||
$notices['editingold'] = $this->msg( 'editingold' )->page( $title )->parseAsBlock();
|
||||
}
|
||||
|
||||
if ( $this->readOnlyMode->isReadOnly() ) {
|
||||
|
@ -343,12 +337,12 @@ class ApiVisualEditor extends ApiBase {
|
|||
wfExpandUrl( Skin::makeInternalOrExternalUrl(
|
||||
$this->msg( 'helppage' )->inContentLanguage()->text()
|
||||
) )
|
||||
)->parseAsBlock();
|
||||
)->page( $title )->parseAsBlock();
|
||||
|
||||
// Page protected from creation
|
||||
if ( $title->getRestrictions( 'create' ) ) {
|
||||
$protectionNotices['titleprotectedwarning'] =
|
||||
$this->msg( 'titleprotectedwarning' )->parseAsBlock() .
|
||||
$this->msg( 'titleprotectedwarning' )->page( $title )->parseAsBlock() .
|
||||
$this->getLastLogEntry( $title, 'protect' );
|
||||
}
|
||||
|
||||
|
@ -386,7 +380,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
// Then it must be protected based on static groups (regular)
|
||||
$noticeMsg = 'protectedpagewarning';
|
||||
}
|
||||
$protectionNotices[$noticeMsg] = $this->msg( $noticeMsg )->parseAsBlock() .
|
||||
$protectionNotices[$noticeMsg] = $this->msg( $noticeMsg )->page( $title )->parseAsBlock() .
|
||||
$this->getLastLogEntry( $title, 'protect' );
|
||||
}
|
||||
|
||||
|
@ -395,7 +389,8 @@ class ApiVisualEditor extends ApiBase {
|
|||
if ( isset( $restrictions['edit'] ) ) {
|
||||
$protectedClasses[] = ' mw-textarea-cprotected';
|
||||
|
||||
$notice = $this->msg( 'cascadeprotectedwarning', count( $sources ) )->parseAsBlock() . '<ul>';
|
||||
$notice = $this->msg( 'cascadeprotectedwarning', count( $sources ) )
|
||||
->page( $title )->parseAsBlock() . '<ul>';
|
||||
// Unfortunately there's no nice way to get only the pages which cause
|
||||
// editing to be restricted
|
||||
foreach ( $sources as $source ) {
|
||||
|
|
Loading…
Reference in a new issue