Jump to content


Problems unserializing an array of objects.

  • Please log in to reply
No replies to this topic

#1 Sipefree

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 March 2006 - 03:19 PM


I'm having problems unserializing an array. Each key in the array contains an object that is instantiated from a class.

When I unserialize the string, it creates all the objects, but does weird stuff to the names of variables. The class itself is a Preference class, for storing different types of preference values, and it has properties such as QXPref::value and QXPref::kind, etc. However, when the array is unserialized, somehow these values become null, even though I can see them in the serialized string. When I used var_dump() and print_r() to show the values, it showed that the original 'value' and 'kind' properties were null, but new ones, 'value:private' and 'kind:private' contained the values that the old ones were supposed to have.

Here's a snippet from the print_r():
    [com.qunix.core.allowGuestMode] => QXPref Object
            [value] => 
            [kind] => 
            [pro] => 0
            [value:private] => 1
            [kind:private] => bool
            [pro:private] => 0
(The 'pro' property is a boolean of the preference's protected status within the web application, and not the object).

This behavior seems very strange and I cannot find any mention of it on the PHP.net manual (mainly because search engines cannot handle ":private").

The properties are marked as public in the class definition, so I've no idea why it's doing this.

Anyone got any clues? I moved my preferences system from an XML definition to a serialized array, and this problem is preventing my web application from starting up, so I can't work on anything until I find the source of this problem.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users