Jump to content

Problems unserializing an array of objects.


Sipefree

Recommended Posts

Hello-

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():
[code]Array
(
    [com.qunix.core.allowGuestMode] => QXPref Object
        (
            [value] =>
            [kind] =>
            [pro] => 0
            [value:private] => 1
            [kind:private] => bool
            [pro:private] => 0
        )[/code]
(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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.