r70428 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70427‎ | r70428 | r70429 >
Date:21:23, 3 August 2010
Author:tparscal
Status:resolved (Comments)
Tags:
Comment:
Made all module options which list files allowed to be given as strings or arrays
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoader.php (modified) (history)
  • /branches/resourceloader/phase3/resources/Resources.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoader.php
@@ -25,27 +25,34 @@
2626 * @example
2727 * // Registers a module with the resource loading system
2828 * ResourceLoader::register( 'foo', array(
29 - * // At minimum you must have a script file
 29+ * // Script or list of scripts to include when implementating the module (required)
3030 * 'script' => 'resources/foo/foo.js',
31 - * // Optionally you can have a style file as well
 31+ * // List of scripts or lists of scripts to include based on the current language
 32+ * 'locales' => array(
 33+ * 'en-gb' => 'resources/foo/locales/en-gb.js',
 34+ * ),
 35+ * // Script or list of scripts to include only when in debug mode
 36+ * 'debug' => 'resources/foo/debug.js',
 37+ * // If this module is going to be loaded before the mediawiki module is ready such as jquery or the mediawiki
 38+ * // module itself, it can be included without special loader wrapping - this will also limit the module to not be
 39+ * // able to specify needs, custom loaders, styles, themes or messages (any of the options below) - raw scripts
 40+ * // get registered as 'ready' after the mediawiki module is ready, so they can be named as dependencies
 41+ * 'raw' => false,
 42+ * // Modules or list of modules which are needed and should be used when generating loader code
 43+ * 'needs' => 'resources/foo/foo.js',
 44+ * // Script or list of scripts which will cause loader code to not be generated - if you are doing something fancy
 45+ * // with your dependencies this gives you a way to use custom registration code
 46+ * 'loader' => 'resources/foo/loader.js',
 47+ * // Style-sheets or list of style-sheets to include
3248 * 'style' => 'resources/foo/foo.css',
33 - * // List of styles to include based on the skin
 49+ * // List of style-sheets or lists of style-sheets to include based on the skin - if no match is found for current
 50+ * // skin, 'default' is used - if default doesn't exist nothing is added
3451 * 'themes' => array(
3552 * 'default' => 'resources/foo/themes/default/foo.css',
3653 * 'vector' => 'resources/foo/themes/vector.foo.css',
3754 * ),
38 - * // List of scripts to include based on the language
39 - * 'locales' => array(
40 - * 'en-gb' => 'resources/foo/locales/en-gb.js',
41 - * ),
42 - * // Only needed if you are doing something fancy with your loader, otherwise one will be generated for you
43 - * 'loader' => 'resources/foo/loader.js',
44 - * // If you need any localized messages brought into the JavaScript environment, list the keys here
 55+ * // List of keys of messages to include
4556 * 'messages' => array( 'foo-hello', 'foo-goodbye' ),
46 - * // Raw scripts are are loaded without using the loader and can not bundle loaders, styles and messages
47 - * 'raw' => false,
48 - * // Debug-only scripts are special scripts that are only loaded when requested and while in debug mode
49 - * 'debug' => false,
5057 * ) );
5158 * @example
5259 * // Responds to a resource loading request
@@ -55,6 +62,7 @@
5663
5764 /* Protected Static Members */
5865
 66+ // List of modules and their options
5967 protected static $modules = array();
6068
6169 /* Protected Static Methods */
@@ -62,10 +70,10 @@
6371 /**
6472 * Runs text through a filter, caching the filtered result for future calls
6573 *
66 - * @param string $filter name of filter to run
67 - * @param string $data text to filter, such as JavaScript or CSS text
68 - * @param string $file path to file being filtered, (optional: only required for CSS to resolve paths)
69 - * @return string filtered data
 74+ * @param {string} $filter name of filter to run
 75+ * @param {string} $data text to filter, such as JavaScript or CSS text
 76+ * @param {string} $file path to file being filtered, (optional: only required for CSS to resolve paths)
 77+ * @return {string} filtered data
7078 */
7179 protected static function filter( $filter, $data, $file = null ) {
7280 global $wgMemc;
@@ -91,27 +99,99 @@
92100 $wgMemc->set( $key, $result );
93101 return $result;
94102 }
 103+ /**
 104+ * Converts a multi-level array into a flat array containing the unique values of all leaf nodes
 105+ *
 106+ * @param {array} $deep mutli-level array to flatten
 107+ * @param {array} $flat array to append flattened values to (used internally)
 108+ * @return {array} flattened array of leaf nodes
 109+ */
 110+ protected static function flatten( $deep, $flat = array() ) {
 111+ foreach ( $deep as $value ) {
 112+ if ( is_array( $value ) ) {
 113+ $flat = self::flatten( $value, $flat );
 114+ } else {
 115+ if ( $value ) {
 116+ $flat[] = $value;
 117+ }
 118+ }
 119+ }
 120+ return array_unique( $flat );
 121+ }
 122+ /**
 123+ * Validates a file or list of files as existing
 124+ *
 125+ * @param {mixed} string file name or array of any depth containing string file names as leaf nodes
 126+ * @throws {MWException} if one or more files do not exist
 127+ */
 128+ protected static function validate( $files ) {
 129+ if ( is_array( $files ) ) {
 130+ $files = self::flatten( $files );
 131+ foreach ( $files as $file ) {
 132+ self::validate( $file );
 133+ }
 134+ } else {
 135+ if ( !file_exists( $files ) ) {
 136+ throw new MWException( 'File does not exist: ' . $files );
 137+ }
 138+ }
 139+ }
 140+ /**
 141+ * Reads a file or list of files and returns them as a string or outputs them into the current output buffer
 142+ *
 143+ * @param {mixed} $files string file name or array of any depth containing string file names as leaf nodes
 144+ * @param {array} $read list of files which have already been read
 145+ * @param
 146+ * @return {mixed} string of read data or null if $passthrough is true
 147+ */
 148+ protected static function read( $files, $passthrough = false ) {
 149+ if ( is_array( $files ) ) {
 150+ $files = self::flatten( $files );
 151+ $contents = '';
 152+ foreach ( $files as $file ) {
 153+ $contents .= self::read( $file );
 154+ }
 155+ return $contents;
 156+ } else {
 157+ if ( $passthrough ) {
 158+ readfile( $files );
 159+ echo "\n";
 160+ return null;
 161+ } else {
 162+ return file_get_contents( $files ) . "\n";
 163+ }
 164+ }
 165+ }
95166
96167 /* Static Methods */
97168
98169 /**
99170 * Registers a module with the ResourceLoader system
100171 *
101 - * @param mixed $module string of name of module or array of name/options pairs
102 - * @param array $options module options (optional when using multiple-registration calling style)
103 - * @return boolean false if there were any errors, in which case one or more modules were not registered
 172+ * @param {mixed} $module string of name of module or array of name/options pairs
 173+ * @param {array} $options module options (optional when using multiple-registration calling style)
 174+ * @return {boolean} false if there were any errors, in which case one or more modules were not registered
104175 *
105176 * $options format:
106177 * array(
107 - * 'script' => [string: path to file],
108 - * 'style' => [string: path to file, optional],
109 - * 'themes' => [array: paths to styles to include, keyed by skin name, optional],
110 - * 'locales' => [array: paths to scripts to include, keyed by locale name, optional],
111 - * 'messages' => [array: message keys, optional],
112 - * 'loader' => [string: path to file, optional],
113 - * 'needs' => [array: names of modules this module needs, optional - ignored if loader is present],
114 - * 'raw' => [boolean: include directly without any loading support, optional],
115 - * 'debug' => [boolean: include in debug mode only, optional],
 178+ * // Required module options
 179+ * 'script' => 'dir/script.js' | array( 'dir/script1.js', 'dir/script2.js' ... ),
 180+ * // Optional module options
 181+ * 'locales' => array(
 182+ * '[locale name]' => 'dir/locale.js' | '[locale name]' => array( 'dir/locale1.js', 'dir/locale2.js' ... )
 183+ * ...
 184+ * ),
 185+ * 'debug' => 'dir/debug.js' | array( 'dir/debug1.js', 'dir/debug2.js' ... ),
 186+ * 'raw' => true | false,
 187+ * // Non-raw module options
 188+ * 'needs' => 'module' | array( 'module1', 'module2' ... )
 189+ * 'loader' => 'dir/loader.js' | array( 'dir/loader1.js', 'dir/loader2.js' ... ),
 190+ * 'style' => 'dir/file.css' | array( 'dir/file1.css', 'dir/file2.css' ... ),
 191+ * 'themes' => array(
 192+ * '[skin name]' => 'dir/theme.css' | '[skin name]' => array( 'dir/theme1.css', 'dir/theme2.css' ... )
 193+ * ...
 194+ * ),
 195+ * 'messages' => array( 'message1', 'message2' ... ),
116196 * )
117197 *
118198 * @todo We need much more clever error reporting, not just in detailing what happened, but in bringing errors to
@@ -120,59 +200,57 @@
121201 public static function register( $module, $options = array() ) {
122202 // Allow multiple modules to be registered in one call
123203 if ( is_array( $module ) && empty( $options ) ) {
124 - $success = true;
125204 foreach ( $module as $name => $options ) {
126 - if ( !self::register( $name, $options ) ) {
127 - $success = false;
128 - }
 205+ self::register( $name, $options );
129206 }
130 - return $success;
 207+ return;
131208 }
132209 // Disallow duplicate registrations
133210 if ( isset( self::$modules[$module] ) ) {
134211 // A module has already been registered by this name
135 - return false;
 212+ throw new MWException( 'Another module has already been registered as ' . $module );
136213 }
137 - // Always include a set of default options in each registration - more data, less isset() checks
 214+ // Always include a set of default options in each registration so we need not exaustively mark all options for
 215+ // all modules when registering and also don't need to worry if the options are set or not later on
138216 $options = array_merge( array(
139217 'script' => null,
140 - 'style' => null,
141 - 'themes' => array(),
142 - 'locales' => array(),
143 - 'messages' => array(),
 218+ 'locales' => null,
 219+ 'raw' => false,
 220+ // An empty array is used for needs to make json_encode output [] instead of null which is shorted and
 221+ // results in easier to work with data on the client
 222+ 'needs' => array(),
144223 'loader' => null,
145 - 'needs' => array(),
146 - 'raw' => false,
147224 'debug' => null,
 225+ 'style' => null,
 226+ 'themes' => null,
 227+ 'messages' => null,
148228 ), $options );
149 - // Validate script option
 229+ // Validate script option - which is required and must reference files that exist
150230 if ( !is_string( $options['script'] ) ) {
151 - // Module does not include a script
152 - return false;
 231+ throw new MWException( 'Module does not include a script: ' . $module );
153232 }
154 - if ( !file_exists( $options['script'] ) ) {
155 - // Script file does not exist
156 - return false;
 233+ // Validate options that reference files
 234+ foreach ( array( 'script', 'locales', 'loader', 'debug', 'style', 'themes' ) as $option ) {
 235+ if ( $options[$option] !== null ) {
 236+ self::validate( $options[$option] );
 237+ }
157238 }
158 - if ( $options['loader'] !== null && !file_exists( $options['loader'] ) ) {
159 - // Loader file does not exist
160 - return false;
161 - }
162 - if ( $options['style'] !== null && !file_exists( $options['style'] ) ) {
163 - // Style file does not exist
164 - return false;
165 - }
 239+ // Attach module
166240 self::$modules[$module] = $options;
167241 }
168 -
 242+ /**
 243+ * Gets a map of all modules and their options
 244+ *
 245+ * @return {array} list of modules and their options
 246+ */
169247 public static function getModules() {
170248 return self::$modules;
171249 }
172 -
173250 /*
174251 * Outputs a response to a resource load-request, including a content-type header
175252 *
176 - * @param WebRequest $request web request object to respond to
 253+ * @param {WebRequest} $request web request object to respond to
 254+ * @param {string} $server web-accessible path to script server
177255 *
178256 * $options format:
179257 * array(
@@ -191,6 +269,7 @@
192270 'lang' => $request->getVal( 'lang', $wgLang->getCode() ),
193271 'skin' => $request->getVal( 'skin', $wgDefaultSkin ),
194272 'debug' => $request->getVal( 'debug' ),
 273+ 'server' => $server,
195274 );
196275 // Mediawiki's WebRequest::getBool is a bit on the annoying side - we need to allow 'true' and 'false' values
197276 // to be converted to boolean true and false
@@ -201,24 +280,26 @@
202281 $lang = $wgLang->factory( $parameters['lang'] );
203282 $parameters['dir'] = $lang->getDir();
204283 }
205 - // Get modules - filtering out any we don't know about
 284+ // Build a list of requested modules excluding unrecognized ones which are collected into a list used to
 285+ // register the unrecognized modules with error status later on
206286 $modules = array();
 287+ $missing = array();
207288 foreach ( explode( '|', $request->getVal( 'modules' ) ) as $module ) {
208289 if ( isset( self::$modules[$module] ) ) {
209290 $modules[] = $module;
 291+ } else {
 292+ $missing[] = $module;
210293 }
211294 }
212295 // Use output buffering
213296 ob_start();
214 - // Output raw modules first
 297+ // Output raw modules first and build a list of raw modules to be registered with ready status later on
215298 $ready = array();
216299 foreach ( $modules as $module ) {
217300 if ( self::$modules[$module]['raw'] ) {
218 - readfile( self::$modules[$module]['script'] );
219 - echo "\n";
 301+ self::read( self::$modules[$module]['script'], true );
220302 if ( $parameters['debug'] && self::$modules[$module]['debug'] ) {
221 - readfile( self::$modules[$module]['debug'] );
222 - echo "\n";
 303+ self::read( self::$modules[$module]['debug'], true );
223304 }
224305 $ready[] = $module;
225306 }
@@ -226,38 +307,36 @@
227308 // Special meta-information for the 'mediawiki' module
228309 if ( in_array( 'mediawiki', $modules ) ) {
229310 /*
230 - * Skin::makeGlobalVariablesScript needs to be modified so that we still output the globals for now, but also
231 - * put them into the initial payload like this:
 311+ * Skin::makeGlobalVariablesScript needs to be modified so that we still output the globals for now, but
 312+ * also put them into the initial payload like this:
232313 *
233 - * // Sets the inital configuration
234 - * mw.config.set( { 'name': 'value', ... } );
 314+ * // Sets the inital configuration
 315+ * mw.config.set( { 'name': 'value', ... } );
235316 *
236317 * Also, the naming of these variables is horrible and sad, hopefully this can be worked on
237318 */
238 - $parameters['server'] = $server;
239319 echo "mw.config.set( " . json_encode( $parameters ) . " );\n";
240 - // Collect all loaders
 320+ // Generate list of registrations and collect all loader scripts
241321 $loaders = array();
242322 $registrations = array();
243323 foreach ( self::$modules as $name => $options ) {
244 - if ( $options['loader'] !== null ) {
 324+ if ( $options['loader'] ) {
245325 $loaders[] = $options['loader'];
246326 } else {
247 - if ( empty( $options['needs'] ) && !in_array( $name, $ready ) ) {
 327+ if ( empty( $options['needs'] ) && !in_array( $name, $ready ) && !in_array( $name, $missing ) ) {
248328 $registrations[$name] = $name;
249329 } else {
250330 $registrations[$name] = array( $name, $options['needs'] );
251331 if ( in_array( $name, $ready ) ) {
252332 $registrations[$name][] = 'ready';
 333+ } else if ( in_array( $name, $missing ) ) {
 334+ $registrations[$name][] = 'missing';
253335 }
254336 }
255337 }
256338 }
257339 // Include loaders
258 - foreach ( array_unique( $loaders ) as $loader ) {
259 - readfile( $loader );
260 - echo "\n";
261 - }
 340+ self::read( $loaders, true );
262341 // Register modules without loaders
263342 echo "mw.loader.register( " . json_encode( array_values( $registrations ) ) . " );\n";
264343 }
@@ -266,22 +345,22 @@
267346 foreach ( $modules as $module ) {
268347 if ( !self::$modules[$module]['raw'] ) {
269348 // Script
270 - $script = file_get_contents( self::$modules[$module]['script'] );
 349+ $script = self::read( self::$modules[$module]['script'] );
271350 // Debug
272351 if ( $parameters['debug'] && self::$modules[$module]['debug'] ) {
273 - $script .= file_get_contents( self::$modules[$module]['debug'] );
 352+ $script .= self::read( self::$modules[$module]['debug'] );
274353 }
275354 // Locale
276355 if ( isset( self::$modules[$module]['locales'][$parameters['lang']] ) ) {
277 - $script .= file_get_contents( self::$modules[$module]['locales'][$parameters['lang']] );
 356+ $script .= self::read( self::$modules[$module]['locales'][$parameters['lang']] );
278357 }
279358 // Style
280 - $style = self::$modules[$module]['style'] ? file_get_contents( self::$modules[$module]['style'] ) : '';
 359+ $style = self::$modules[$module]['style'] ? self::read( self::$modules[$module]['style'] ) : '';
281360 // Theme
282361 if ( isset( self::$modules[$module]['themes'][$parameters['skin']] ) ) {
283 - $style .= file_get_contents( self::$modules[$module]['themes'][$parameters['skin']] );
 362+ $style .= self::read( self::$modules[$module]['themes'][$parameters['skin']] );
284363 } else if ( isset( self::$modules[$module]['themes']['default'] ) ) {
285 - $style .= file_get_contents( self::$modules[$module]['themes']['default'] );
 364+ $style .= self::read( self::$modules[$module]['themes']['default'] );
286365 }
287366 if ( $style !== '' ) {
288367 if ( $parameters['dir'] == 'rtl' ) {
Index: branches/resourceloader/phase3/resources/Resources.php
@@ -17,27 +17,33 @@
1818 'jquery.ui.core' => array(
1919 'script' => 'resources/jquery/ui/jquery.ui.core.js',
2020 'themes' => array(
21 - 'default' => 'resources/jquery/ui/themes/default/jquery.ui.theme.css',
22 - 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.theme.css',
 21+ 'default' => array(
 22+ 'resources/jquery/ui/themes/default/jquery.ui.core.css',
 23+ 'resources/jquery/ui/themes/default/jquery.ui.theme.css',
 24+ ),
 25+ 'vector' => array(
 26+ 'resources/jquery/ui/themes/vector/jquery.ui.core.css',
 27+ 'resources/jquery/ui/themes/vector/jquery.ui.theme.css',
 28+ ),
2329 ),
24 - 'needs' => array( 'jquery' ),
 30+ 'needs' => 'jquery',
2531 ),
2632 'jquery.ui.widget' => array(
2733 'script' => 'resources/jquery/ui/jquery.ui.widget.js',
28 - 'needs' => array( 'jquery.ui.core' ),
 34+ 'needs' => 'jquery.ui.core',
2935 ),
3036 'jquery.ui.mouse' => array(
3137 'script' => 'resources/jquery/ui/jquery.ui.mouse.js',
32 - 'needs' => array( 'jquery' ),
 38+ 'needs' => 'jquery',
3339 ),
3440 'jquery.ui.position' => array(
3541 'script' => 'resources/jquery/ui/jquery.ui.position.js',
36 - 'needs' => array( 'jquery' ),
 42+ 'needs' => 'jquery',
3743 ),
3844 // Interactions
3945 'jquery.ui.draggable' => array(
4046 'script' => 'resources/jquery/ui/jquery.ui.draggable.js',
41 - 'needs' => array( 'jquery.ui.core' ),
 47+ 'needs' => 'jquery.ui.core',
4248 ),
4349 'jquery.ui.droppable' => array(
4450 'script' => 'resources/jquery/ui/jquery.ui.droppable.js',
@@ -49,7 +55,7 @@
5056 'default' => 'resources/jquery/ui/themes/default/jquery.ui.resizable.css',
5157 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.resizable.css',
5258 ),
53 - 'needs' => array( 'jquery.ui.core' ),
 59+ 'needs' => 'jquery.ui.core',
5460 ),
5561 'jquery.ui.selectable' => array(
5662 'script' => 'resources/jquery/ui/jquery.ui.selectable.js',
@@ -57,16 +63,16 @@
5864 'default' => 'resources/jquery/ui/themes/default/jquery.ui.selectable.css',
5965 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.selectable.css',
6066 ),
61 - 'needs' => array( 'jquery.ui.core' ),
 67+ 'needs' => 'jquery.ui.core',
6268 ),
6369 'jquery.ui.sortable' => array(
6470 'script' => 'resources/jquery/ui/jquery.ui.sortable.js',
65 - 'needs' => array( 'jquery.ui.core' ),
 71+ 'needs' => 'jquery.ui.core',
6672 ),
6773 // Widgets
6874 'jquery.ui.accordion' => array(
6975 'script' => 'resources/jquery/ui/jquery.ui.accordion.js',
70 - 'needs' => array( 'jquery.ui.core' ),
 76+ 'needs' => 'jquery.ui.core',
7177 'themes' => array(
7278 'default' => 'resources/jquery/ui/themes/default/jquery.ui.accordion.css',
7379 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.accordion.css',
@@ -90,7 +96,7 @@
9197 ),
9298 'jquery.ui.datepicker' => array(
9399 'script' => 'resources/jquery/ui/jquery.ui.datepicker.js',
94 - 'needs' => array( 'jquery.ui.core' ),
 100+ 'needs' => 'jquery.ui.core',
95101 'themes' => array(
96102 'default' => 'resources/jquery/ui/themes/default/jquery.ui.datepicker.css',
97103 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.datepicker.css',
@@ -152,7 +158,7 @@
153159 ),
154160 'jquery.ui.dialog' => array(
155161 'script' => 'resources/jquery/ui/jquery.ui.dialog.js',
156 - 'needs' => array( 'jquery.ui.core' ),
 162+ 'needs' => 'jquery.ui.core',
157163 'themes' => array(
158164 'default' => 'resources/jquery/ui/themes/default/jquery.ui.dialog.css',
159165 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.dialog.css',
@@ -160,7 +166,7 @@
161167 ),
162168 'jquery.ui.progressbar' => array(
163169 'script' => 'resources/jquery/ui/jquery.ui.progressbar.js',
164 - 'needs' => array( 'jquery.ui.core' ),
 170+ 'needs' => 'jquery.ui.core',
165171 'themes' => array(
166172 'default' => 'resources/jquery/ui/themes/default/jquery.ui.progressbar.css',
167173 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.progressbar.css',
@@ -176,7 +182,7 @@
177183 ),
178184 'jquery.ui.tabs' => array(
179185 'script' => 'resources/jquery/ui/jquery.ui.tabs.js',
180 - 'needs' => array( 'jquery.ui.core' ),
 186+ 'needs' => 'jquery.ui.core',
181187 'themes' => array(
182188 'default' => 'resources/jquery/ui/themes/default/jquery.ui.tabs.css',
183189 'vector' => 'resources/jquery/ui/themes/vector/jquery.ui.tabs.css',
@@ -185,55 +191,55 @@
186192 // Effects
187193 'jquery.effects.core' => array(
188194 'script' => 'resources/jquery/effects/jquery.effects.core.js',
189 - 'needs' => array( 'jquery' ),
 195+ 'needs' => 'jquery',
190196 ),
191197 'jquery.effects.blind' => array(
192198 'script' => 'resources/jquery/effects/jquery.effects.blind.js',
193 - 'needs' => array( 'jquery.effects.core' ),
 199+ 'needs' => 'jquery.effects.core',
194200 ),
195201 'jquery.effects.bounce' => array(
196202 'script' => 'resources/jquery/effects/jquery.effects.bounce.js',
197 - 'needs' => array( 'jquery.effects.core' ),
 203+ 'needs' => 'jquery.effects.core',
198204 ),
199205 'jquery.effects.clip' => array(
200206 'script' => 'resources/jquery/effects/jquery.effects.clip.js',
201 - 'needs' => array( 'jquery.effects.core' ),
 207+ 'needs' => 'jquery.effects.core',
202208 ),
203209 'jquery.effects.drop' => array(
204210 'script' => 'resources/jquery/effects/jquery.effects.drop.js',
205 - 'needs' => array( 'jquery.effects.core' ),
 211+ 'needs' => 'jquery.effects.core',
206212 ),
207213 'jquery.effects.explode' => array(
208214 'script' => 'resources/jquery/effects/jquery.effects.explode.js',
209 - 'needs' => array( 'jquery.effects.core' ),
 215+ 'needs' => 'jquery.effects.core',
210216 ),
211217 'jquery.effects.fold' => array(
212218 'script' => 'resources/jquery/effects/jquery.effects.fold.js',
213 - 'needs' => array( 'jquery.effects.core' ),
 219+ 'needs' => 'jquery.effects.core',
214220 ),
215221 'jquery.effects.highlight' => array(
216222 'script' => 'resources/jquery/effects/jquery.effects.highlight.js',
217 - 'needs' => array( 'jquery.effects.core' ),
 223+ 'needs' => 'jquery.effects.core',
218224 ),
219225 'jquery.effects.pulsate' => array(
220226 'script' => 'resources/jquery/effects/jquery.effects.pulsate.js',
221 - 'needs' => array( 'jquery.effects.core' ),
 227+ 'needs' => 'jquery.effects.core',
222228 ),
223229 'jquery.effects.scale' => array(
224230 'script' => 'resources/jquery/effects/jquery.effects.scale.js',
225 - 'needs' => array( 'jquery.effects.core' ),
 231+ 'needs' => 'jquery.effects.core',
226232 ),
227233 'jquery.effects.shake' => array(
228234 'script' => 'resources/jquery/effects/jquery.effects.shake.js',
229 - 'needs' => array( 'jquery.effects.core' ),
 235+ 'needs' => 'jquery.effects.core',
230236 ),
231237 'jquery.effects.slide' => array(
232238 'script' => 'resources/jquery/effects/jquery.effects.slide.js',
233 - 'needs' => array( 'jquery.effects.core' ),
 239+ 'needs' => 'jquery.effects.core',
234240 ),
235241 'jquery.effects.transfer' => array(
236242 'script' => 'resources/jquery/effects/jquery.effects.transfer.js',
237 - 'needs' => array( 'jquery.effects.core' ),
 243+ 'needs' => 'jquery.effects.core',
238244 ),
239245
240246 /* MediaWiki */
@@ -248,75 +254,75 @@
249255
250256 'mediawiki.legacy.ajax' => array(
251257 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.ajax.js',
252 - 'needs' => array( 'mediawiki' ),
 258+ 'needs' => 'mediawiki',
253259 ),
254260 'mediawiki.legacy.ajaxwatch' => array(
255261 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.ajaxwatch.js',
256 - 'needs' => array( 'mediawiki' ),
 262+ 'needs' => 'mediawiki',
257263 ),
258264 'mediawiki.legacy.block' => array(
259265 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.block.js',
260 - 'needs' => array( 'mediawiki' ),
 266+ 'needs' => 'mediawiki',
261267 ),
262268 'mediawiki.legacy.changepassword' => array(
263269 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.changepassword.js',
264 - 'needs' => array( 'mediawiki' ),
 270+ 'needs' => 'mediawiki',
265271 ),
266272 'mediawiki.legacy.edit' => array(
267273 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.edit.js',
268 - 'needs' => array( 'mediawiki' ),
 274+ 'needs' => 'mediawiki',
269275 ),
270276 'mediawiki.legacy.enhancedchanges' => array(
271277 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.enhancedchanges.js',
272 - 'needs' => array( 'mediawiki' ),
 278+ 'needs' => 'mediawiki',
273279 ),
274280 'mediawiki.legacy.history' => array(
275281 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.history.js',
276 - 'needs' => array( 'mediawiki' ),
 282+ 'needs' => 'mediawiki',
277283 ),
278284 'mediawiki.legacy.htmlform' => array(
279285 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.htmlform.js',
280 - 'needs' => array( 'mediawiki' ),
 286+ 'needs' => 'mediawiki',
281287 ),
282288 'mediawiki.legacy.IEFixes' => array(
283289 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.IEFixes.js',
284 - 'needs' => array( 'mediawiki' ),
 290+ 'needs' => 'mediawiki',
285291 ),
286292 'mediawiki.legacy.metadata' => array(
287293 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.metadata.js',
288 - 'needs' => array( 'mediawiki' ),
 294+ 'needs' => 'mediawiki',
289295 ),
290296 'mediawiki.legacy.mwsuggest' => array(
291297 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.mwsuggest.js',
292 - 'needs' => array( 'mediawiki' ),
 298+ 'needs' => 'mediawiki',
293299 ),
294300 'mediawiki.legacy.prefs' => array(
295301 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.prefs.js',
296 - 'needs' => array( 'mediawiki' ),
 302+ 'needs' => 'mediawiki',
297303 ),
298304 'mediawiki.legacy.preview' => array(
299305 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.preview.js',
300 - 'needs' => array( 'mediawiki' ),
 306+ 'needs' => 'mediawiki',
301307 ),
302308 'mediawiki.legacy.protect' => array(
303309 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.protect.js',
304 - 'needs' => array( 'mediawiki' ),
 310+ 'needs' => 'mediawiki',
305311 ),
306312 'mediawiki.legacy.rightclickedit' => array(
307313 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.rightclickedit.js',
308 - 'needs' => array( 'mediawiki' ),
 314+ 'needs' => 'mediawiki',
309315 ),
310316 'mediawiki.legacy.search' => array(
311317 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.search.js',
312 - 'needs' => array( 'mediawiki' ),
 318+ 'needs' => 'mediawiki',
313319 ),
314320 'mediawiki.legacy.upload' => array(
315321 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.upload.js',
316 - 'needs' => array( 'mediawiki' ),
 322+ 'needs' => 'mediawiki',
317323 ),
318324 'mediawiki.legacy.wikibits' => array(
319325 'script' => 'resources/mediawiki/legacy/mediawiki.legacy.wikibits.js',
320 - 'needs' => array( 'mediawiki' ),
 326+ 'needs' => 'mediawiki',
321327 ),
322328
323329 /* MediaWiki Utilities */
@@ -338,24 +344,24 @@
339345
340346 'test' => array(
341347 'script' => 'resources/test/test.js',
342 - 'needs' => array( 'foo' ),
 348+ 'needs' => 'foo',
343349 'style' => 'resources/test/test.css',
344350 ),
345351 'foo' => array(
346352 'script' => 'resources/test/foo.js',
347 - 'needs' => array( 'bar' ),
 353+ 'needs' => 'bar',
348354 'style' => 'resources/test/foo.css',
349355 'messages' => array( 'january', 'february', 'march', 'april', 'may', 'june' ),
350356 ),
351357 'bar' => array(
352358 'script' => 'resources/test/bar.js',
353 - 'needs' => array( 'buz' ),
 359+ 'needs' => 'buz',
354360 'style' => 'resources/test/bar.css',
355361 'messages' => array( 'july', 'august', 'september', 'october', 'november', 'december' ),
356362 ),
357363 'buz' => array(
358364 'script' => 'resources/test/buz.js',
359 - 'needs' => array( 'baz' ),
 365+ 'needs' => 'baz',
360366 'style' => 'resources/test/buz.css',
361367 ),
362368 'baz' => array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r70466Updated documentation for ResourceLoader::read() which solves continuity erro...tparscal17:29, 4 August 2010

Comments

#Comment by Catrope (talk | contribs)   14:56, 4 August 2010
+	/**
+	 * Reads a file or list of files and returns them as a string or outputs them into the current output buffer
+	 * 
+	 * @param {mixed} $files string file name or array of any depth containing string file names as leaf nodes
+	 * @param {array} $read list of files which have already been read
+	 * @param
+	 * @return {mixed} string of read data or null if $passthrough is true
+	 */
+	protected static function read( $files, $passthrough = false ) {

The documented parameter names don't match the actual parameter names. Also, what's up with the braces around the types?

#Comment by Trevor Parscal (WMF) (talk | contribs)   17:33, 4 August 2010

Good catch - r70466 resolves this. Also, depending on the documentation spec you are working with the braces are normal syntax for types - afaik doxygen is cool with it, and it lets other systems function as well. I think I wrote this this way out of a new habbit - is it a problem?

#Comment by Catrope (talk | contribs)   17:36, 4 August 2010

No, it's fine, just wondering.

Status & tagging log