Re: Destructor not called when extending SimpleXMLElement
| From: | Nick Chalk | Date: | Tue, 03 Jul 2012 10:16:09 +0000 |
| Subject: | Re: Destructor not called when extending SimpleXMLElement | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318386@lists.php.net to get a copy of this message | ||
Thanks Erwin and Matijn.
On 2 July 2012 17:32, Matijn Woudt <tijnema@gmail.com> wrote:
> This is most likely a bug in PHP. A deconstructor is called when there
> are no references left to the object. Since this class uses the libXML
> library, it is likely that there are still references from the libXML
> open on the object, which is why it will never be destroyed.
> Anyway, you should report this bug to the PHP devs (at bugs.php.net).
Yes, that sounds plausible. As a quick hack, I tried adding a
destructor to the SimpleXMLElement extension, but that wasn't called
either.
I'll submit a bug report.
> If you really need this, it's probably best to create a class that
> does not really extend SimpleXMLElement, but you create one inside the
> constructor, and just forward all function calls to the
> SimpleXMLElement object you've created in the constructor.
I've been playing with that today, and it looks like a workable solution.
Thanks for your help!
Nick.
--
Nick Chalk.
Loadbalancer.org Ltd.
Phone: +44 (0)870 443 8779
http://www.loadbalancer.org/