User:PleaseStand patch fixes bug 34972
authorRob Moen <rmoen@users.mediawiki.org>
Tue, 13 Mar 2012 17:57:54 +0000 (17:57 +0000)
committerRob Moen <rmoen@users.mediawiki.org>
Tue, 13 Mar 2012 17:57:54 +0000 (17:57 +0000)
includes/OutputPage.php
resources/mediawiki.action/mediawiki.action.watch.ajax.js

index bb02c01..47f6641 100644 (file)
@@ -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();
index 00fcbb3..f5f09f5 100644 (file)
@@ -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
                                );