OutputPage->getJSVars: Maintain symmetry between JS & PHP vars
authorOri Livneh <ori@wikimedia.org>
Thu, 26 Sep 2013 05:03:16 +0000 (22:03 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 27 Sep 2013 09:42:03 +0000 (11:42 +0200)
The function is more difficult to read than it need be by dint of some things
two names. I can't be the only one who finds 'wgCurRevisionId' => $latestRevID
ugly, right? Anyhow, lots of JS code depends on the JS variable names, whereas
the PHP variables exist only in the scope of that method, so it's clear that
it's the PHP names that should be brought in line.

Change-Id: Ibddd5d2fc8d75e0ade18ff3433714d52605f2911

includes/OutputPage.php

index 6904432..cc3f9b3 100644 (file)
@@ -2966,24 +2966,24 @@ $templates
        public function getJSVars() {
                global $wgContLang;
 
-               $latestRevID = 0;
-               $pageID = 0;
-               $canonicalName = false; # bug 21115
+               $curRevisionId = 0;
+               $articleId = 0;
+               $canonicalSpecialPageName = false; # bug 21115
 
                $title = $this->getTitle();
                $ns = $title->getNamespace();
-               $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $title->getNsText();
+               $canonicalNamespace = 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() );
+                       list( $canonicalSpecialPageName, /*...*/ ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
                } elseif ( $this->canUseWikiPage() ) {
                        $wikiPage = $this->getWikiPage();
-                       $latestRevID = $wikiPage->getLatest();
-                       $pageID = $wikiPage->getId();
+                       $curRevisionId = $wikiPage->getLatest();
+                       $articleId = $wikiPage->getId();
                }
 
                $lang = $title->getPageLanguage();
@@ -3005,14 +3005,14 @@ $templates
                $user = $this->getUser();
 
                $vars = array(
-                       'wgCanonicalNamespace' => $nsname,
-                       'wgCanonicalSpecialPageName' => $canonicalName,
+                       'wgCanonicalNamespace' => $canonicalNamespace,
+                       'wgCanonicalSpecialPageName' => $canonicalSpecialPageName,
                        'wgNamespaceNumber' => $title->getNamespace(),
                        'wgPageName' => $title->getPrefixedDBkey(),
                        'wgTitle' => $title->getText(),
-                       'wgCurRevisionId' => $latestRevID,
+                       'wgCurRevisionId' => $curRevisionId,
                        'wgRevisionId' => (int)$this->getRevisionId(),
-                       'wgArticleId' => $pageID,
+                       'wgArticleId' => $articleId,
                        'wgIsArticle' => $this->isArticle(),
                        'wgIsRedirect' => $title->isRedirect(),
                        'wgAction' => Action::getActionName( $this->getContext() ),