r94766 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94765‎ | r94766 | r94767 >
Date:14:55, 17 August 2011
Author:catrope
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2574,7 +2574,7 @@
25752575 // We're on a preview of a JS subpage
25762576 // Exclude this page from the user module in case it's in there (bug 26283)
25772577 $scripts .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_SCRIPTS, false,
2578 - array( 'excludepage' => $this->getTitle()->getPrefixedText() )
 2578+ array( 'excludepage' => $this->getTitle()->getPrefixedDBkey() )
25792579 );
25802580 // Load the previewed JS
25812581 $scripts .= Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n";
@@ -2979,10 +2979,10 @@
29802980 // We're on a preview of a CSS subpage
29812981 // Exclude this page from the user module in case it's in there (bug 26283)
29822982 $otherTags .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_STYLES, false,
2983 - array( 'excludepage' => $this->getTitle()->getPrefixedText() )
 2983+ array( 'excludepage' => $this->getTitle()->getPrefixedDBkey() )
29842984 );
29852985 // Load the previewed CSS
2986 - $otherTags .= Html::inlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) );;
 2986+ $otherTags .= Html::inlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) );
29872987 } else {
29882988 // Load the user styles normally
29892989 $moduleStyles[] = 'user';
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php
@@ -34,13 +34,17 @@
3535 */
3636 protected function getPages( ResourceLoaderContext $context ) {
3737 if ( $context->getUser() ) {
 38+ // Get the normalized title of the user's user page
3839 $username = $context->getUser();
 40+ $userpageTitle = Title::makeTitleSafe( NS_USER, $username );
 41+ $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works
 42+
3943 $pages = array(
40 - "User:$username/common.js" => array( 'type' => 'script' ),
41 - "User:$username/" . $context->getSkin() . '.js' =>
 44+ "$userpage/common.js" => array( 'type' => 'script' ),
 45+ "$userpage/" . $context->getSkin() . '.js' =>
4246 array( 'type' => 'script' ),
43 - "User:$username/common.css" => array( 'type' => 'style' ),
44 - "User:$username/" . $context->getSkin() . '.css' =>
 47+ "$userpage/common.css" => array( 'type' => 'style' ),
 48+ "$userpage/" . $context->getSkin() . '.css' =>
4549 array( 'type' => 'style' ),
4650 );
4751
@@ -49,6 +53,8 @@
5054 // parameter will be set to the name of the page we need to exclude.
5155 $excludepage = $context->getRequest()->getVal( 'excludepage' );
5256 if ( isset( $pages[$excludepage] ) ) {
 57+ // This works because $excludepage is generated with getPrefixedDBkey(),
 58+ // just like the keys in $pages[] above
5359 unset( $pages[$excludepage] );
5460 }
5561 return $pages;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94421(bug 26283) Previewing user JS/CSS pages doesn't load other user JS/CSS pagescatrope17:27, 13 August 2011

Status & tagging log