| Index: trunk/phase3/RELEASE-NOTES-1.19 |
| — | — | @@ -44,6 +44,7 @@ |
| 45 | 45 | * (bug 30264) Changed installer-generated LocalSettings.php to use require_once() |
| 46 | 46 | instead require() for included extensions. |
| 47 | 47 | * Do not convert text in the user interface language to another script. |
| | 48 | +* (bug 26283) Previewing user JS/CSS pages doesn't load other user JS/CSS pages |
| 48 | 49 | |
| 49 | 50 | === API changes in 1.19 === |
| 50 | 51 | * (bug 19838) siprop=interwikimap can now use the interwiki cache. |
| Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php |
| — | — | @@ -35,7 +35,7 @@ |
| 36 | 36 | protected function getPages( ResourceLoaderContext $context ) { |
| 37 | 37 | if ( $context->getUser() ) { |
| 38 | 38 | $username = $context->getUser(); |
| 39 | | - return array( |
| | 39 | + $pages = array( |
| 40 | 40 | "User:$username/common.js" => array( 'type' => 'script' ), |
| 41 | 41 | "User:$username/" . $context->getSkin() . '.js' => |
| 42 | 42 | array( 'type' => 'script' ), |
| — | — | @@ -43,6 +43,15 @@ |
| 44 | 44 | "User:$username/" . $context->getSkin() . '.css' => |
| 45 | 45 | array( 'type' => 'style' ), |
| 46 | 46 | ); |
| | 47 | + |
| | 48 | + // Hack for bug 26283: if we're on a preview page for a CSS/JS page, |
| | 49 | + // we need to exclude that page from this module. In that case, the excludepage |
| | 50 | + // parameter will be set to the name of the page we need to exclude. |
| | 51 | + $excludepage = $context->getRequest()->getVal( 'excludepage' ); |
| | 52 | + if ( isset( $pages[$excludepage] ) ) { |
| | 53 | + unset( $pages[$excludepage] ); |
| | 54 | + } |
| | 55 | + return $pages; |
| 47 | 56 | } |
| 48 | 57 | return array(); |
| 49 | 58 | } |
| Index: trunk/phase3/includes/OutputPage.php |
| — | — | @@ -2347,19 +2347,20 @@ |
| 2348 | 2348 | |
| 2349 | 2349 | /** |
| 2350 | 2350 | * TODO: Document |
| 2351 | | - * @param $modules Array/string with the module name |
| | 2351 | + * @param $modules Array/string with the module name(s) |
| 2352 | 2352 | * @param $only String ResourceLoaderModule TYPE_ class constant |
| 2353 | 2353 | * @param $useESI boolean |
| | 2354 | + * @param $extraQuery Array with extra query parameters to add to each request. array( param => value ) |
| 2354 | 2355 | * @return string html <script> and <style> tags |
| 2355 | 2356 | */ |
| 2356 | | - protected function makeResourceLoaderLink( $modules, $only, $useESI = false ) { |
| | 2357 | + protected function makeResourceLoaderLink( $modules, $only, $useESI = false, array $extraQuery = array() ) { |
| 2357 | 2358 | global $wgLoadScript, $wgResourceLoaderUseESI, |
| 2358 | 2359 | $wgResourceLoaderInlinePrivateModules; |
| 2359 | 2360 | $baseQuery = array( |
| 2360 | 2361 | 'lang' => $this->getContext()->getLang()->getCode(), |
| 2361 | 2362 | 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false', |
| 2362 | 2363 | 'skin' => $this->getSkin()->getSkinName(), |
| 2363 | | - ); |
| | 2364 | + ) + $extraQuery; |
| 2364 | 2365 | if ( $only !== ResourceLoaderModule::TYPE_COMBINED ) { |
| 2365 | 2366 | $baseQuery['only'] = $only; |
| 2366 | 2367 | } |
| — | — | @@ -2577,11 +2578,15 @@ |
| 2578 | 2579 | if ( $wgAllowUserJs && $this->getUser()->isLoggedIn() ) { |
| 2579 | 2580 | if( $this->getTitle() && $this->getTitle()->isJsSubpage() && $this->userCanPreview() ) { |
| 2580 | 2581 | # XXX: additional security check/prompt? |
| | 2582 | + // We're on a preview of a JS subpage |
| | 2583 | + // Exclude this page from the user module in case it's in there (bug 26283) |
| | 2584 | + $scripts .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_SCRIPTS, false, |
| | 2585 | + array( 'excludepage' => $this->getTitle()->getPrefixedText() ) |
| | 2586 | + ); |
| | 2587 | + // Load the previewed JS |
| 2581 | 2588 | $scripts .= Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n"; |
| 2582 | 2589 | } else { |
| 2583 | | - # @todo FIXME: This means that User:Me/Common.js doesn't load when previewing |
| 2584 | | - # User:Me/Vector.js, and vice versa (bug 26283) |
| 2585 | | - |
| | 2590 | + // Include the user module normally |
| 2586 | 2591 | // We can't do $userScripts[] = 'user'; because the user module would end up |
| 2587 | 2592 | // being wrapped in a closure, so load it raw like 'site' |
| 2588 | 2593 | $scripts .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_SCRIPTS ); |
| — | — | @@ -2961,6 +2966,7 @@ |
| 2962 | 2967 | // Add ResourceLoader styles |
| 2963 | 2968 | // Split the styles into four groups |
| 2964 | 2969 | $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array(), 'noscript' => array() ); |
| | 2970 | + $otherTags = ''; // Tags to append after the normal <link> tags |
| 2965 | 2971 | $resourceLoader = $this->getResourceLoader(); |
| 2966 | 2972 | |
| 2967 | 2973 | $moduleStyles = $this->getModuleStyles(); |
| — | — | @@ -2977,9 +2983,15 @@ |
| 2978 | 2984 | // Per-user custom styles |
| 2979 | 2985 | if ( $wgAllowUserCss ) { |
| 2980 | 2986 | if ( $this->getTitle()->isCssSubpage() && $this->userCanPreview() ) { |
| 2981 | | - // @todo FIXME: Properly escape the cdata! |
| 2982 | | - $this->addInlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) ); |
| | 2987 | + // We're on a preview of a CSS subpage |
| | 2988 | + // Exclude this page from the user module in case it's in there (bug 26283) |
| | 2989 | + $otherTags .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_STYLES, false, |
| | 2990 | + array( 'excludepage' => $this->getTitle()->getPrefixedText() ) |
| | 2991 | + ); |
| | 2992 | + // Load the previewed CSS |
| | 2993 | + $otherTags .= Html::inlineStyle( $this->getRequest()->getText( 'wpTextbox1' ) );; |
| 2983 | 2994 | } else { |
| | 2995 | + // Load the user styles normally |
| 2984 | 2996 | $moduleStyles[] = 'user'; |
| 2985 | 2997 | } |
| 2986 | 2998 | } |
| — | — | @@ -3015,6 +3027,9 @@ |
| 3016 | 3028 | ResourceLoaderModule::TYPE_STYLES |
| 3017 | 3029 | ); |
| 3018 | 3030 | } |
| | 3031 | + |
| | 3032 | + // Add stuff in $otherTags (previewed user CSS if applicable) |
| | 3033 | + $ret .= $otherTags; |
| 3019 | 3034 | return $ret; |
| 3020 | 3035 | } |
| 3021 | 3036 | |