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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.