#36600 [Opn->Bgs]: DOMDocument::loadXML() within derived class broken
| From: | rrichards@php.net | Date: | Fri, 03 Mar 2006 15:25:01 +0000 |
| Subject: | #36600 [Opn->Bgs]: DOMDocument::loadXML() within derived class broken | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-93887@lists.php.net to get a copy of this message | ||
ID: 36600
Updated by: rrichards@php.net
Reported By: georg at howen dot de
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: Linux, Win XP
PHP Version: 5.1.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
loadXML() is not a true static function. It is just allowed to be
called statically. When called statically within a method of an
instantiated DOMDocument object it acts as if the method had been
called directly from the object itself rather than statically.
use the syntax as demonstrated by the behavior of $internal_doc1
creation in this case.
Previous Comments:
------------------------------------------------------------------------
[2006-03-03 11:42:24] georg at howen dot de
Changed status back to open since I believe that
$internal_doc2 = DOMDocument::loadXML($xml);
is a static call that does not return what it should.
If I didn't get something right I am really sorry, but I still believe
this is a bug.
------------------------------------------------------------------------
[2006-03-03 10:38:40] georg at howen dot de
Hi,
I thought I was aware of that. But isn't
$internal_doc2 = DOMDocument::loadXML($xml);
a static call to DOMDocument? That's the one that works fine _outside_
of a DOMDocument but not inside a class that extends DOMDocument.
------------------------------------------------------------------------
[2006-03-03 10:20:33] bjori@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
DOMDocument::loadXML will return DOMDocument only when called staticly
------------------------------------------------------------------------
[2006-03-03 09:55:29] georg at howen dot de
Description:
------------
If you extend DOMDocument and try to use DOMDocument::loadXML() on a
new DOMDocument within the extended class, this function will return
true instead of a new instance of DOMDocument.
Reproduce code:
---------------
<?php
class xDOMDocument extends DOMDocument {
public function newDom($xml) {
$internal_doc1 = new DOMDocument;
$internal_doc1->loadXML($xml);
print_r($internal_doc1);
$internal_doc2 = DOMDocument::loadXML($xml);
print_r($internal_doc2);
}
}
$xml = '<def>Test</def>';
$dom = new xDOMDocument();
$dom->newDom($xml);
Expected result:
----------------
DOMDocument Object
(
)
DOMDocument Object
(
)
Actual result:
--------------
DOMDocument Object
(
)
1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36600&edit=1