r74679 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74678‎ | r74679 | r74680 >
Date:17:52, 12 October 2010
Author:tparscal
Status:ok
Tags:
Comment:
Simplifies r73680 by letting FormatJson::encode do it's magic with handling null and string values correctly.
Modified paths:
  • /trunk/phase3/includes/ResourceLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ResourceLoader.php
@@ -430,18 +430,8 @@
431431 public static function makeCustomLoaderScript( $name, $version, $dependencies, $group, $script ) {
432432 $name = Xml::escapeJsString( $name );
433433 $version = (int) $version > 1 ? (int) $version : 1;
434 - if ( is_array( $dependencies ) ) {
435 - $dependencies = FormatJson::encode( $dependencies );
436 - } else if ( is_string( $dependencies ) ) {
437 - $dependencies = "'" . Xml::escapeJsString( $dependencies ) . "'";
438 - } else {
439 - $dependencies = 'null';
440 - }
441 - if ( is_string( $group ) ) {
442 - $group = "'" . Xml::escapeJsString( $group ) . "'";
443 - } else {
444 - $group = 'null';
445 - }
 434+ $dependencies = FormatJson::encode( $dependencies );
 435+ $group = FormatJson::encode( $group );
446436 $script = str_replace( "\n", "\n\t", trim( $script ) );
447437 return "( function( name, version, dependencies, group ) {\n\t$script\n} )" .
448438 "( '$name', $version, $dependencies, $group );\n";
@@ -454,18 +444,8 @@
455445 } else {
456446 $name = Xml::escapeJsString( $name );
457447 $version = (int) $version > 1 ? (int) $version : 1;
458 - if ( is_array( $dependencies ) ) {
459 - $dependencies = FormatJson::encode( $dependencies );
460 - } else if ( is_string( $dependencies ) ) {
461 - $dependencies = "'" . Xml::escapeJsString( $dependencies ) . "'";
462 - } else {
463 - $dependencies = 'null';
464 - }
465 - if ( is_string( $group ) ) {
466 - $group = "'" . Xml::escapeJsString( $group ) . "'";
467 - } else {
468 - $group = 'null';
469 - }
 448+ $dependencies = FormatJson::encode( $dependencies );
 449+ $group = FormatJson::encode( $group );
470450 return "mediaWiki.loader.register( '$name', $version, $dependencies, $group );\n";
471451 }
472452 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73680Moved more generated javascript to ResourceLoader functions. Cleaned some thi...tparscal21:03, 24 September 2010

Status & tagging log