Unserialize with namespaces

Working on modernizing some rather old code, I pulled in composer and performed some psr-4 namespacing/autoloading configuration (really large app).

The main process is building out the initial data structure from a soap based backend, objects are being created and functioning fine. However, I’ve run into snag.

This app has the option to save an instance of a job which simply dumps the object model with state to an xml file (in the form of cdata), which gives the user the ability to reload the saved file at a later time without having to go back through the soap interface.

The problem I seem to be having is the unserialize process (with the new cdata) does not like the namespace naming convention, e.g., what used to be ProjectManager is now MyApp\ProjectManager and when I attempt to unserialize I get a big fat false.

In hopes of determining what the problem was I used this site:
https://www.functions-online.com/unserialize.html
which indicated that using MyApp\ProjectManager as the object name was illegal. This is just one of many objects that are now getting saved with the namespace structure and I’m trying to find a way to make it work with the namespaces intact. Any help on this would be greatly apprecicated.

thanks,
Karl

Should be simple if you supplied some relevant code but did you try to use the Fully Qualified Name with the trailing backslash?

e.g.

\MyApp\ProjectManager

turns out the errors reported from that validation site was a red herring. there was some formatted html that accidentally made it into the payload that was causing the problem.
Bottom line, we have to move away from this method for storing and reloading application state. It’s too unpredictable.

Sponsor our Newsletter | Privacy Policy | Terms of Service