r93363 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93362‎ | r93363 | r93364 >
Date:05:48, 28 July 2011
Author:catrope
Status:ok
Tags:
Comment:
Make mw.user.options and mw.user.tokens work in debug mode in IE. Now that mw.user is a separate module, we have to make these depend on that and make sure dependencies are actually processed.
* Make ResourceLoaderUserOptionsModule and ResourceLoaderUserTokensModule depend on mw.user
* Load mw.user.{tokens,options,groups} load as TYPE_COMBINED instead of TYPE_SCRIPT. The latter wouldn't wrap the code in mw.loader.implement()
** ...but make sure 'user' (user scripts) is excluded, that one needs to not be wrapped in a closure
* Make TYPE_COMBINED actually work in makeResourceLoaderLink()
* Add a comment in makeModuleResponse() to explain what the weird is_array( $scripts ) stuff is all about
* Add FIXME about how mw.user.options should split off the CSS part into a separate module
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2403,8 +2403,10 @@
24042404 'lang' => $this->getContext()->getLang()->getCode(),
24052405 'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false',
24062406 'skin' => $this->getSkin()->getSkinName(),
2407 - 'only' => $only,
24082407 );
 2408+ if ( $only !== ResourceLoaderModule::TYPE_COMBINED ) {
 2409+ $baseQuery['only'] = $only;
 2410+ }
24092411 // Propagate printable and handheld parameters if present
24102412 if ( $this->isPrintable() ) {
24112413 $baseQuery['printable'] = 1;
@@ -2622,11 +2624,14 @@
26232625 $scripts .= Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n";
26242626 } else {
26252627 # @todo FIXME: This means that User:Me/Common.js doesn't load when previewing
2626 - # User:Me/Vector.js, and vice versa (bug26283)
2627 - $userScripts[] = 'user';
 2628+ # User:Me/Vector.js, and vice versa (bug 26283)
 2629+
 2630+ // We can't do $userScripts[] = 'user'; because the user module would end up
 2631+ // being wrapped in a closure, so load it raw like 'site'
 2632+ $scripts .= $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_SCRIPTS );
26282633 }
26292634 }
2630 - $scripts .= $this->makeResourceLoaderLink( $userScripts, ResourceLoaderModule::TYPE_SCRIPTS );
 2635+ $scripts .= $this->makeResourceLoaderLink( $userScripts, ResourceLoaderModule::TYPE_COMBINED );
26312636
26322637 return $scripts;
26332638 }
Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -549,8 +549,10 @@
550550 switch ( $context->getOnly() ) {
551551 case 'scripts':
552552 if ( is_string( $scripts ) ) {
 553+ // Load scripts raw...
553554 $out .= $scripts;
554555 } elseif ( is_array( $scripts ) ) {
 556+ // ...except when $scripts is an array of URLs
555557 $out .= self::makeLoaderImplementScript( $name, $scripts, array(), array() );
556558 }
557559 break;
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php
@@ -84,6 +84,8 @@
8585 * @return array
8686 */
8787 public function getStyles( ResourceLoaderContext $context ) {
 88+ // FIXME: This stuff should really be in its own module, because it gets double-loaded otherwise
 89+ // (once through a <link>, once when embedded as JS)
8890 global $wgAllowUserCssPrefs;
8991
9092 if ( $wgAllowUserCssPrefs ) {
@@ -129,4 +131,8 @@
130132 public function getGroup() {
131133 return 'private';
132134 }
 135+
 136+ public function getDependencies() {
 137+ return array( 'mediawiki.user' );
 138+ }
133139 }
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php
@@ -60,4 +60,8 @@
6161 public function getGroup() {
6262 return 'private';
6363 }
 64+
 65+ public function getDependencies() {
 66+ return array( 'mediawiki.user' );
 67+ }
6468 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r111027Revert r111023 and r111024, they broke user.options . I'll fix this properly ...catrope10:59, 9 February 2012
r111029(bug 34289) user.options CSS loaded twice. Fixed by splitting off the CSS par...catrope11:04, 9 February 2012

Status & tagging log