Index: GlobalFunctions.php =================================================================== --- GlobalFunctions.php (revision 67579) +++ GlobalFunctions.php (working copy) @@ -3238,18 +3238,20 @@ return $output; } -/* Recursively converts the parameter (an object) to an array with the same data */ -function wfObjectToArray( $object, $recursive = true ) { - $array = array(); - foreach ( get_object_vars($object) as $key => $value ) { - if ( is_object($value) && $recursive ) { - $value = wfObjectToArray( $value ); - } - - $array[$key] = $value; - } - - return $array; +/* Recursively converts the parameter (an object) to an array with the same data */ +function wfObjectToArray( $objOrArray, $recursive = true ) { + $array = array(); + 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 ); + } + + $array[$key] = $value; + } + + return $array; } /**