From: Brion Vibber Date: Sun, 13 Feb 2011 23:04:34 +0000 (+0000) Subject: * (bug 26250, bug 23817) Fix wfObjectToArray() to descend into arrays; fixes processi... X-Git-Tag: 1.31.0-rc.0~32004 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=7d2049c7e3de4932ebb70c8d90d30c5131a3e18d;p=lhc%2Fweb%2Fwiklou.git * (bug 26250, bug 23817) Fix wfObjectToArray() to descend into arrays; fixes processing of JSON return values for ForeignAPIRepo when native json module not present --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index e88afdad36..3b427422dc 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3244,10 +3244,13 @@ function wfArrayInsertAfter( $array, $insert, $after ) { } /* Recursively converts the parameter (an object) to an array with the same data */ -function wfObjectToArray( $object, $recursive = true ) { +function wfObjectToArray( $objOrArray, $recursive = true ) { $array = array(); - foreach ( get_object_vars( $object ) as $key => $value ) { - if ( is_object( $value ) && $recursive ) { + if( is_object( $objOrArray ) ) { + $objOrArray = get_object_vars( $objOrArray ); + } + foreach ( $objOrArray as $key => $value ) { + if ( $recursive && ( is_object( $value ) || is_array( $value ) ) ) { $value = wfObjectToArray( $value ); }