From 72c33b4523c98673087cc2cdb435141533c16723 Mon Sep 17 00:00:00 2001 From: Rob Moen Date: Tue, 13 Mar 2012 17:57:54 +0000 Subject: [PATCH] User:PleaseStand patch fixes bug 34972 --- includes/OutputPage.php | 5 +++++ .../mediawiki.action/mediawiki.action.watch.ajax.js | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index bb02c0118c..47f6641619 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2840,6 +2840,10 @@ $templates $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() ) { @@ -2881,6 +2885,7 @@ $templates 'wgPageContentLanguage' => $lang->getCode(), 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, + 'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey(), ); if ( $wgContLang->hasVariants() ) { $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); diff --git a/resources/mediawiki.action/mediawiki.action.watch.ajax.js b/resources/mediawiki.action/mediawiki.action.watch.ajax.js index 00fcbb3e1e..f5f09f52a1 100644 --- a/resources/mediawiki.action/mediawiki.action.watch.ajax.js +++ b/resources/mediawiki.action/mediawiki.action.watch.ajax.js @@ -4,6 +4,11 @@ */ ( 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. @@ -24,7 +29,7 @@ function updateWatchLink( $link, action, state ) { ( accesskeyTip ? ' ' + accesskeyTip[0] : '' ) ) .attr( 'href', mw.util.wikiScript() + '?' + $.param({ - title: mw.config.get( 'wgPageName' ), + title: title, action: action }) ); @@ -98,7 +103,7 @@ $( document ).ready( function() { api = new mw.Api(); api[action]( - mw.config.get( 'wgPageName' ), + title, // Success function( watchResponse ) { var otherAction = action === 'watch' ? 'unwatch' : 'watch', @@ -129,10 +134,10 @@ $( document ).ready( function() { 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 ); -- 2.20.1