php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27882 xml_set_object(...) seems to not working
Submitted: 2004-04-06 05:00 UTC Modified: 2004-04-14 08:16 UTC
From: david dot seidel at one-jinx dot de Assigned:
Status: Closed Package: XML related
PHP Version: 5CVS-2004-04-06 (dev) OS: Linux (2.4.19)
Private report: No CVE-ID: None
 [2004-04-06 05:00 UTC] david dot seidel at one-jinx dot de
Description:
------------
If written a class that uses xml_set_object(...). In PHP5.0.0RC1 this works correctly, but in PHP Version 5.0.0RC2-dev (php5-200404060630) my script produces a lot of warnings like "Warning: xml_parse() [function.xml-parse]: Unable to call handler tag_open() in ...". When I use function instead of the methods, everything seems to work correctly.

Reproduce code:
---------------
class blwTemplateEngine
...
public function __construct(...) {
$this->parser = xml_parser_create();
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, "tag_open", "tag_close");
xml_set_character_data_handler($this->parser, "cdata");
$this->setOption(XML_OPTION_CASE_FOLDING, false);
}
...
protected final function tag_open($parser, $tag, $attributes) {}
protected final function tag_close($parser, $tag) {}
protected final function cdata($parser, $cdata) {}
...
}


Expected result:
----------------
render a Template

Actual result:
--------------
Warning: xml_parse() [function.xml-parse]: Unable to call handler cdata() in /srv/www/htdocs/bluewonder_neo/bluewonder/base/template/blwTemplateEngine.php on line 156

line 156:
if(!xml_parse($this->parser, $data)) {
			throw new Exception("XML-Parser-Error: Error in ".$this->templatePath." - ".xml_error_string(xml_get_error_code($this->parser)). " (Error-Code: ".xml_get_error_code($this->parser).") at line ".xml_get_current_line_number($this->parser)." and column ".xml_get_current_column_number($this->parser));
		}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-07 10:59 UTC] sniper@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.


 [2004-04-08 07:11 UTC] david dot seidel at one-jinx dot de
class XMLParser {
    var $parser = null;
    public function __construct($xml) {
        $this->parser = xml_parser_create();
        xml_set_object($this->parser, $this);
        xml_set_element_handler($this->parser, "tag_open", "tag_close");
        xml_set_character_data_handler($this->parser, "cdata");
        xml_parser_set_option ( $this->parser, XML_OPTION_CASE_FOLDING,false);
    }
    public function tag_open($parser, $tag, $attributes){}
    public function tag_close($parser, $tag) {}
    public function cdata($parser, $data) {}
}
$string="<?xml version="1.0"?><root>test</root>";
$foo = new XMLParser($string);
 [2004-04-08 10:39 UTC] rrichards@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2004-04-12 17:55 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2004-04-14 06:58 UTC] david dot seidel at one-jinx dot de
It seems that now everything works fine. Thanks.
 [2004-04-14 08:16 UTC] derick@php.net
Then we close the report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC