From:             kenashkov at gmail dot com
Operating system: Fedora Core 4
PHP version:      4.4.2
PHP Bug Type:     XML related
Bug description:  Problem assigning multiple objects with XML parser within 
them to one variable

Description:
------------
When assigning multiple times to ane variable an object which contains a
XML parser, there is a problem when the xml_parse is called. The parser
can not call the registered handlers.
The problem can be avoided if the variable is unset before the second
call, or using $doc1 =& new xml_doc() for every assignment.

Reproduce code:
---------------
<?
class xml_doc
{
function xml_doc()
        {
        $this->res = xml_parser_create_ns();
        xml_set_object($this->res,$this);
        xml_set_element_handler($this->res,'start_element','end_element');
        }
        
function load_string($string)
        {
        xml_parse($this->res,$string);
        }
        
function start_element()
        {
        }
        
function end_element()
        {
        }
}

$str = '<?xml version="1" encoding="UTF-8"
standalone="yes"?><root></root>';
$doc1 = new xml_doc();
$doc1->load_string($str);
//unset($doc1);//this solves the problem
//or using $doc1 =& new xml_doc(); in every assignment
$doc1 = new xml_doc();
$doc1->load_string($str);
?>

Expected result:
----------------
Nothing really... it is too simple to do real parsing.

Actual result:
--------------
Warning: xml_parse() [function.xml-parse.html]: Unable to call handler
start_element() in file.php on line 13

Warning: xml_parse() [function.xml-parse.html]: Unable to call handler
end_element() in file.php on line 13

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

Reply via email to