$ns = $title->getNamespace();
$nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $title->getNsText();
+ // Get the relevant title so that AJAX features can use the correct page name
+ // when making API requests from certain special pages (bug 34972).
+ $relevantTitle = $this->getSkin()->getRelevantTitle();
+
if ( $ns == NS_SPECIAL ) {
list( $canonicalName, /*...*/ ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
} elseif ( $this->canUseWikiPage() ) {
'wgPageContentLanguage' => $lang->getCode(),
'wgSeparatorTransformTable' => $compactSeparatorTransTable,
'wgDigitTransformTable' => $compactDigitTransTable,
+ 'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey(),
);
if ( $wgContLang->hasVariants() ) {
$vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
*/
( function ( $, mw, undefined ) {
+/**
+ * The name of the page to watch or unwatch.
+ */
+var title = mw.config.get( 'wgRelevantPageName', mw.config.get( 'wgPageName' ) );
+
/**
* Update the link text, link href attribute and (if applicable)
* "loading" class.
( accesskeyTip ? ' ' + accesskeyTip[0] : '' )
)
.attr( 'href', mw.util.wikiScript() + '?' + $.param({
- title: mw.config.get( 'wgPageName' ),
+ title: title,
action: action
})
);
api = new mw.Api();
api[action](
- mw.config.get( 'wgPageName' ),
+ title,
// Success
function( watchResponse ) {
var otherAction = action === 'watch' ? 'unwatch' : 'watch',
updateWatchLink( $link, action );
// Format error message
- var cleanTitle = mw.config.get( 'wgPageName' ).replace( /_/g, ' ' );
+ var cleanTitle = title.replace( /_/g, ' ' );
var link = mw.html.element(
'a', {
- 'href': mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) ),
+ 'href': mw.util.wikiGetlink( title ),
'title': cleanTitle
}, cleanTitle
);