Edit report at http://bugs.php.net/bug.php?id=52782&edit=1

 ID:                 52782
 Comment by:         bugs dot php dot net at moesen dot nu
 Reported by:        bugs dot php dot net at moesen dot nu
 Summary:            DOMDocument subclass forgotten using ->ownerDocument
                     after closure
 Status:             Open
 Type:               Bug
 Package:            DOM XML related
 Operating System:   GNU/Linux 2.6.26-2-686 (Debian)
 PHP Version:        5.3SVN-2010-09-06 (snap)
 Block user comment: N

 New Comment:

Is there anything I can do to get a confirmation on this? I tried #php
on several networks, but they referred me to Freenode, where #php was
full.


Previous Comments:
------------------------------------------------------------------------
[2010-09-06 15:43:15] bugs dot php dot net at moesen dot nu

Err, my apologies for not cleaning up the path names. An oversight on my
part.

------------------------------------------------------------------------
[2010-09-06 15:35:59] bugs dot php dot net at moesen dot nu

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 this bug report at http://bugs.php.net/bug.php?id=52782&edit=1

Reply via email to