Author: supreme_geek_overlord
Description:
The wfObjectToArray global function, when called with $recursive = true, does not recurse through properties of the object that are arrays. As a result, if objects are nested inside these arrays, they will not be converted.
An example of a object to array conversion function that *does* handle nested arrays is at http://www.phpro.org/examples/Convert-Object-To-Array-With-PHP.html (at the bottom).
I encountered this problem while trying to use the ForeignAPIRepo feature on my wiki with a PHP installation that does not have the builtin JSON functions. It uses FormatJson::decode(), which falls back on Services_JSON to decode the data. FormatJson then converts the decoded object to an array using wfObjectToArray, which is where this failure happens. The end result is this error message:
Fatal error: Cannot use object of type stdClass as array in /home/mscs/common/devel/www/html/projects/beowulf/wiki.real/includes/filerepo/ForeignAPIFile.php on line 102
Interestingly, Services_JSON has its own way of returning arrays instead of objects--the flag SERVICES_JSON_LOOSE_TYPE. If FormatJson used this instead, it could bypass wfObjectToArray completely. Perhaps there are two bugs here.
I will try to submit patches tomorrow.
Version: 1.16.x
Severity: normal