https://bugzilla.wikimedia.org/show_bug.cgi?id=23817

           Summary: wfObjectToArray does not recurse into arrays
           Product: MediaWiki
           Version: 1.16.0beta3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: General/Unknown
        AssignedTo: wikibugs-l@lists.wikimedia.org
        ReportedBy: supreme_geek_overl...@yahoo.com


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.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to