* (bug 26250, bug 23817) Fix wfObjectToArray() to descend into arrays; fixes processi...
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 13 Feb 2011 23:04:34 +0000 (23:04 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 13 Feb 2011 23:04:34 +0000 (23:04 +0000)
includes/GlobalFunctions.php

index e88afda..3b42742 100644 (file)
@@ -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 );
                }