r75055 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75054‎ | r75055 | r75056 >
Date:22:53, 19 October 2010
Author:tparscal
Status:resolved (Comments)
Tags:
Comment:
Fixed case where tryForKey can sometimes not return an array
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -317,9 +317,9 @@
318318 */
319319 protected static function tryForKey( $list, $key, $fallback = null ) {
320320 if ( isset( $list[$key] ) && is_array( $list[$key] ) ) {
321 - return $list[$key];
 321+ return (array) $list[$key];
322322 } else if ( is_string( $fallback ) && isset( $list[$fallback] ) ) {
323 - return $list[$fallback];
 323+ return (array) $list[$fallback];
324324 }
325325 return array();
326326 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r75108Improves on r75055, improving comment accuracy, and removing useless casting.tparscal20:56, 20 October 2010

Comments

#Comment by Brion VIBBER (talk | contribs)   04:36, 20 October 2010

In the first case we've already checked is_array(), so the coercion probably isn't needed. I'm a bit lost on the second; does the input allow arrays with non-array content, and if so why is that only being used for the fallback key?

The doc comments don't match the definition either, which throws me off (doc says $map, but function says $list).

Status & tagging log