Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F6856
wfObjectToArray_recursive_fix.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 21 2014, 11:08 PM
2014-11-21 23:08:38 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
wfObjectToArray_recursive_fix.patch
View Options
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
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6394
Default Alt Text
wfObjectToArray_recursive_fix.patch (1 KB)
Attached To
Mode
T25817: wfObjectToArray does not recurse into arrays
Attached
Detach File
Event Timeline
Log In to Comment