From:             
Operating system: Linux
PHP version:      5.3.2
Package:          DOM XML related
Bug Type:         Bug
Bug description:Extending DOM classes work only if copy of object present

Description:
------------
Extending some DOM classes (f.e. DOMDOcument, DOMElement I think others,
but not 

tested) work. But when such elemenmt appended to the document, additional 

information lost. Meantime, when copy of object saved alsewere, all work as


expected.



First mention of this bug and initial workaround in comment 

http://php.net/manual/tr/book.dom.php#80613 by ryoroxdahouse at hotmail dot
com.



I make automattical workaround like ( 

http://hinikato.blogspot.com/2009/10/domelement.html?

showComment=1270202266600#c284093039037001302 ):

class MyElement extends DOMElement

{

public function __construct($name, $value = null, $uri = null) {

parent::__construct($name, $value, $uri);

$GLOBALS['PHP_HACK_DOM_ELEMENT'][spl_object_hash($this)] = $this; //Note, 

reference is not enough :(

}



public function __destruct() {

unset($GLOBALS['PHP_HACK_DOM_ELEMENT'][spl_object_hash($this)]);

}

}



But as we need object copy, not just reference it requires double of
memmory!

Test script:
---------------
<?

class MyElement extends DOMElement{}

$doc = new DOMDocument();

$doc->appendChild(new MyElement('test'));

var_dump($doc->documentElement);

?>

Expected result:
----------------
object(MyElement)#4 (0) { } 

Actual result:
--------------
object(DOMElement)#4 (0) { }

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51462&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51462&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51462&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51462&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51462&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51462&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51462&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51462&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51462&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51462&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51462&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51462&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51462&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51462&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51462&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51462&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51462&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51462&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51462&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51462&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51462&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51462&r=mysqlcfg

Reply via email to