php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63742 Stack tree DOMDocument::registerNodeClass incorrect
Submitted: 2012-12-11 16:50 UTC Modified: 2012-12-11 17:02 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: giso at connectholland dot nl Assigned:
Status: Open Package: DOM XML related
PHP Version: 5.3.3 OS: Linux / Debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-12-11 16:50 UTC] giso at connectholland dot nl
Description:
------------
When using DOMDocument::registerNodeClass for both DOMElement and DOMNode a 
DOMElement does nog get to be a child of the registered DOMNode class

Test script:
---------------
<?php
class MyDOMDocument extends DOMDocument {
	public function __construct($version = null, $encoding = null) {
		parent::__construct($version, $encoding);
		
		$this->registerNodeClass("DOMNode", "MyDOMNode");
		$this->registerNodeClass("DOMElement", "MyDOMElement");
        }
}

$dom = new MyDOMDocument();
$dom->loadXML("<root/>");

$parent_class_names = array();
$parent_class_name = get_class($dom->documentElement);
do {
    $parent_class_names[] = $parent_class_name;
} while($parent_class_name = get_parent_class($parent_class_name));

var_dump($parent_class_names);
?>

Expected result:
----------------
array (size=4)
  0 => string 'MyDOMElement' (length=12)
  1 => string 'DOMElement' (length=10)
  2 => string 'MyDOMNode' (length=9)
  3 => string 'DOMNode' (length=7)


Actual result:
--------------
array (size=3)
  0 => string 'MyDOMElement' (length=12)
  1 => string 'DOMElement' (length=10)
  2 => string 'DOMNode' (length=7)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-11 17:02 UTC] giso at connectholland dot nl
-PHP Version: 5.3.19 +PHP Version: 5.3.3
 [2012-12-11 17:02 UTC] giso at connectholland dot nl
Add 

class MyDOMNode extends DOMNode {}
class MyDOMElement extends DOMElement {}

to the reproduction script
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC