r105877 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105876‎ | r105877 | r105878 >
Date:14:06, 12 December 2011
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Fix for JSON parsing change in r105849
Modified paths:
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -447,8 +447,11 @@
448448 */
449449 static function parseTree( $tree, &$retrieved_values ) {
450450 foreach ( $tree as $key => $val ) {
 451+ // TODO - this logic could probably be a little nicer.
451452 if ( is_array( $val ) && count( $val ) > 1 ) {
452453 self::parseTree( $val, $retrieved_values );
 454+ } elseif ( is_array( $val ) && count( $val ) == 1 && is_array( $val[0] ) ) {
 455+ self::parseTree( $val[0], $retrieved_values );
453456 } else {
454457 // If it's an array with just one element,
455458 // treat it like a regular value.

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105849Removed unnecessary check at top, improved JSON parsing, added handling for c...yaron02:56, 12 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   14:49, 12 December 2011

Why isn't FormatJson::decode sufficient?

#Comment by Yaron Koren (talk | contribs)   15:08, 12 December 2011

Oh - I had no idea that class existed. Thanks for letting me know about it. It looks like it's been in place since MW 1.16; External Data in theory still supports MW 1.13+, but maybe it's time to get rid of some of that backwards compatibility.

#Comment by Nikerabbit (talk | contribs)   15:09, 12 December 2011

And you are guaranteed to get working JSON implementation that way.

#Comment by Yaron Koren (talk | contribs)   15:11, 12 December 2011

Right, that makes sense - assuming, of course, the user has MW 1.16 or higher.

Status & tagging log