[Tickets #5604] Re: ListMessages endless loop

bugs at bugs.horde.org bugs at bugs.horde.org
Wed Aug 8 03:13:47 UTC 2007


Ticket URL: http://bugs.horde.org/ticket/?id=5604
 Ticket             | 5604
 Updated By         | vokac at kmlinux.fjfi.cvut.cz
 Summary            | ListMessages endless loop
 Queue              | DIMP
 Version            | 1.0-ALPHA
 Type               | Bug
 State              | Feedback
 Priority           | 1. Low
 Owners             | 

vokac at kmlinux.fjfi.cvut.cz (2007-08-07 20:13) wrote:

>> We need to cast it to an object, otherwise the JSON would probably
>> look like this:
>> [1, 2, 3]
>> instead of:
>> {'1': 1, '2': 2, '3': 3}
> This is precisely the reason.  In javascript land, we are accessing 
> the array via the message index (our message indices just happen to 
> look like integers), which is a string value, rather than an integer 
> value because the latter would indicate the position in the JS array.

Well, but if you look at your implementation of JSON serialization, you
handle asociative arrays differently than normal arrays. See also comment
in lib/Horde/Serialize/JSON.php:133

            /* As per JSON spec if any array key is not an integer we
             * must treat the the whole array as an object. We also
             * try to catch a sparsely populated associative array
             * with numeric keys here because some JS engines will
             * create an array with empty indexes up to max_index
             * which can cause memory issues and because the keys,
             * which may be relevant, will be remapped otherwise.
             * As per the ECMA and JSON specification an object may
             * have any string as a property. Unfortunately due to a
             * hole in the ECMA specification if the key is a ECMA
             * reserved word or starts with a digit the parameter is
             * only accessible using ECMAScript's bracket notation. */

According me it means, that casting associative array with string keys to
object is not required (and with cast to object it doesn't work on probably
somehow broken PHP in RHEL5/CentOS5 - I'll try to figure out the reason why
get_object_vars doesn't work on this system, but right now I tested PHP
5.1.6 compiled from sources and it doesn't work either).

More information about the bugs mailing list