Page MenuHomePhabricator

wfObjectToArray_recursive_fix.patch

Authored By
bzimport
Nov 21 2014, 11:08 PM
Size
1 KB
Referenced Files
None
Subscribers
None

wfObjectToArray_recursive_fix.patch

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;
}
/**

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6394
Default Alt Text
wfObjectToArray_recursive_fix.patch (1 KB)

Event Timeline