From bbb37969909b518b60aaeddebe5038ab32ea8095 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 17 Aug 2011 14:55:06 +0000 Subject: [PATCH] Followup r94421 which, per CR, broke in non-English content languages because of key mismatches due to localized namespace names. Now ensuring all titles go through getPrefixedDBkey() before we compare them, so they're always normalized. This also ensures we don't get underscore vs. space confusion, which is something that the previous code did right by accident. --- includes/OutputPage.php | 6 +++--- .../resourceloader/ResourceLoaderUserModule.php | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 1f09798ee2..33e4bbd007 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2574,7 +2574,7 @@ $templates // We're on a preview of a JS subpage // Exclude this page from the user module in case it's in there (bug 26283) $scripts .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_SCRIPTS, false, - array( 'excludepage' => $this->getTitle()->getPrefixedText() ) + array( 'excludepage' => $this->getTitle()->getPrefixedDBkey() ) ); // Load the previewed JS $scripts .= Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n"; @@ -2979,10 +2979,10 @@ $templates // We're on a preview of a CSS subpage // Exclude this page from the user module in case it's in there (bug 26283) $otherTags .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_STYLES, false, - array( 'excludepage' => $this->getTitle()->getPrefixedText() ) + array( 'excludepage' => $this->getTitle()->getPrefixedDBkey() ) ); // Load the previewed CSS - $otherTags .= Html::inlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) );; + $otherTags .= Html::inlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) ); } else { // Load the user styles normally $moduleStyles[] = 'user'; diff --git a/includes/resourceloader/ResourceLoaderUserModule.php b/includes/resourceloader/ResourceLoaderUserModule.php index e70aa51b0a..3c6f61e2f9 100644 --- a/includes/resourceloader/ResourceLoaderUserModule.php +++ b/includes/resourceloader/ResourceLoaderUserModule.php @@ -34,13 +34,17 @@ class ResourceLoaderUserModule extends ResourceLoaderWikiModule { */ protected function getPages( ResourceLoaderContext $context ) { if ( $context->getUser() ) { + // Get the normalized title of the user's user page $username = $context->getUser(); + $userpageTitle = Title::makeTitleSafe( NS_USER, $username ); + $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works + $pages = array( - "User:$username/common.js" => array( 'type' => 'script' ), - "User:$username/" . $context->getSkin() . '.js' => + "$userpage/common.js" => array( 'type' => 'script' ), + "$userpage/" . $context->getSkin() . '.js' => array( 'type' => 'script' ), - "User:$username/common.css" => array( 'type' => 'style' ), - "User:$username/" . $context->getSkin() . '.css' => + "$userpage/common.css" => array( 'type' => 'style' ), + "$userpage/" . $context->getSkin() . '.css' => array( 'type' => 'style' ), ); @@ -49,6 +53,8 @@ class ResourceLoaderUserModule extends ResourceLoaderWikiModule { // parameter will be set to the name of the page we need to exclude. $excludepage = $context->getRequest()->getVal( 'excludepage' ); if ( isset( $pages[$excludepage] ) ) { + // This works because $excludepage is generated with getPrefixedDBkey(), + // just like the keys in $pages[] above unset( $pages[$excludepage] ); } return $pages; -- 2.20.1