From: Operating system: GNU/Linux 2.6.26-2-686 (Debian) PHP version: 5.3SVN-2010-09-06 (snap) Package: DOM XML related Bug Type: Bug Bug description:DOMDocument subclass forgotten using ->ownerDocument after closure
Description: ------------ We have custom XML document and element classes that extend the original DOMDocument and DOMElement classes for convenience. There is a class that uses an instance of XmlElement obtained via a callback specified at construction time. That XmlElement works fine and stays that way. However, when we get its ownerDocument outside of the closure, the result is not an XmlDocument but a DOMDocument. I cannot see a single reason why. I tried several options, and it only seems to happen with that closure. I have checked versions 5.3.1, 5.3.2, 5.3.3 and now the latest 5.3.4 snapshot compiled with './configure && make'. Test script: --------------- http://codepad.org/hvrNh86K The original code uses a lot of namespaces and extends XmlDocument, but this is a much more minimal test case. Also try the "Uncomment this" code to see what /does/ work. Expected result: ---------------- *** Calling the callback directly... dom-fail.php:110: $container: XmlElement: <div id="content"/> dom-fail.php:111: $container->ownerDocument: XmlDocument; debug: object(XmlDocument)#2 (0) refcount(1){ } *** Calling callback from constructor()... dom-fail.php:110: $container: XmlElement: <div id="content"/> dom-fail.php:111: $container->ownerDocument: XmlDocument; debug: object(XmlDocument)#2 (0) refcount(1){ } *** In constructor, after check on $container: dom-fail.php:95: $container: XmlElement: <div id="content"/> dom-fail.php:96: $container->ownerDocument: XmlDocument; debug: object(XmlDocument)#2 (0) refcount(1){ } SUCCESS! Actual result: -------------- *** Calling the callback directly... dom-fail.php:110: $container: XmlElement: <div id="content"/> dom-fail.php:111: $container->ownerDocument: XmlDocument; debug: object(XmlDocument)#2 (0) refcount(1){ } *** Calling callback from constructor()... dom-fail.php:110: $container: XmlElement: <div id="content"/> dom-fail.php:111: $container->ownerDocument: XmlDocument; debug: object(XmlDocument)#2 (0) refcount(1){ } *** In constructor, after check on $container: dom-fail.php:95: $container: XmlElement: <div id="content"/> dom-fail.php:96: $container->ownerDocument: DOMDocument; debug: object(DOMDocument)#2 (0) refcount(1){ } PHP Fatal error: Call to undefined method DOMDocument::append() in /home/jmoe/fuckingpieceofshitfuckfuckfucksocks/dom-fail.php on line 100 -- Edit bug report at http://bugs.php.net/bug.php?id=52782&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52782&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52782&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52782&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52782&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52782&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52782&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52782&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52782&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52782&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52782&r=support Expected behavior: http://bugs.php.net/fix.php?id=52782&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52782&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52782&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52782&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52782&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52782&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52782&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52782&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52782&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52782&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52782&r=mysqlcfg