r105849 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105848‎ | r105849 | r105850 >
Date:02:56, 12 December 2011
Author:yaron
Status:deferred
Tags:
Comment:
Removed unnecessary check at top, improved JSON parsing, added handling for case of CURLOPT_SSL_VERIFYPEER not defined
Modified paths:
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -3,10 +3,6 @@
44 * Utility functions for External Data
55 */
66
7 -if ( !defined( 'MEDIAWIKI' ) ) {
8 - die( 'This file is a MediaWiki extension; it is not a valid entry point' );
9 -}
10 -
117 class EDUtils {
128 // how many times to try an HTTP request
139 private static $http_number_of_tries = 3;
@@ -451,14 +447,20 @@
452448 */
453449 static function parseTree( $tree, &$retrieved_values ) {
454450 foreach ( $tree as $key => $val ) {
455 - if ( is_array( $val ) ) {
 451+ if ( is_array( $val ) && count( $val ) > 1 ) {
456452 self::parseTree( $val, $retrieved_values );
457453 } else {
 454+ // If it's an array with just one element,
 455+ // treat it like a regular value.
 456+ if ( is_array( $val ) ) {
 457+ $val = $val[0];
 458+ }
458459 $key = strtolower( $key );
459 - if ( array_key_exists( $key, $retrieved_values ) )
 460+ if ( array_key_exists( $key, $retrieved_values ) ) {
460461 $retrieved_values[$key][] = $val;
461 - else
 462+ } else {
462463 $retrieved_values[$key] = array( $val );
 464+ }
463465 }
464466 }
465467 }
@@ -492,6 +494,10 @@
493495 if ( $edgAllowSSL ) {
494496 // The hardcoded 'CURLOPT_SSL_VERIFYPEER' is
495497 // needed for MW < 1.17
 498+ if ( !defined( 'CURLOPT_SSL_VERIFYPEER' ) ) {
 499+ print 'CURLOPT_SSL_VERIFYPEER is not defined on this system - you must set $edgAllowSSL = "false".';
 500+ return;
 501+ }
496502 return Http::get( $url, 'default', array( CURLOPT_SSL_VERIFYPEER => false, 'sslVerifyCert' => false, 'followRedirects' => false ) );
497503 } else {
498504 return Http::get( $url );

Follow-up revisions

RevisionCommit summaryAuthorDate
r105877Fix for JSON parsing change in r105849yaron14:06, 12 December 2011

Status & tagging log