-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SimpleXMLElement Serialization #14742
Comments
This could be useful, but it's not so trivial as one might expect... Only putting the XML code into the serialization is not enough because:
Furthermore:
Then we have SimpleXMLIterator which extends SimpleXMLElement. I'd propose to keep blocking serialization of that subclass because the complexity/usefulness trade-off is not worth it imo. (When would people serialize an iterator?) |
I had guessed there was more too it than just using the xml, and i agree it should encapsulate any extended functionality where feasible. Definitely agree with not serialising iterators. I was asking as im working on 'caching' some functionality with var_exports which parses xml files, and exporting the instantiated SimpleXMLElement would remove some the parsing stage, but it seems there isnt currently a way to do that (if there is please let me know) |
No there's no way to do that right now. And we can't really avoid the parsing even if we have var_export because we still need to create the underlying libxml objects. |
Description
From what i can tell the SimpleXMLElement class can be very easily serialised/unserialised which would be very useful for use with var_exports and keeping state between requests without the need for the stored source for the xml, would it be possible to have __serialise() which outputs the string representation of the xml, and __unserialise() which just calls simplexml_load_string() and returns the new instance?
the __set_state() method would also be useful but serialise would be beneficial to a larger audience
The text was updated successfully, but these errors were encountered: