From:             black at scene-si dot org
Operating system: debian
PHP version:      5.0.0
PHP Bug Type:     XML related
Bug description:  xml_* functions throw non descriptive error, compared to php4

Description:
------------
when validating an incorrectly formated xml file, the errors from php
5.0.0 are vaguely descriptive, outputting some constant name and not a
human readable error message

Reproduce code:
---------------
#!/usr/bin/php5
<?php

if ($argc<2) {
        echo "Usage: ".$PHP_SELF." file.xml\n";
        exit;
}

$file = $argv[1];
$depth = array();

function startElement($parser, $name, $attrs) {}
function endElement($parser, $name) {}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!($fp = fopen($file, "r"))) {
   die("could not open XML input");
}

while ($data = fread($fp, 4096)) {
   if (!xml_parse($xml_parser, $data, feof($fp))) {
       die(sprintf("XML error: %s at line %d",
                   xml_error_string(xml_get_error_code($xml_parser)),
                   xml_get_current_line_number($xml_parser)));
   }
}
xml_parser_free($xml_parser);


Expected result:
----------------
XML error: mismatched tag at line 14

(from php4, identical code)

Actual result:
--------------
XML error: XML_ERR_TAG_NAME_MISMATCH at line 14

(php5 output)

-- 
Edit bug report at http://bugs.php.net/?id=29657&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29657&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29657&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29657&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29657&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29657&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29657&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29657&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29657&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29657&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29657&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29657&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29657&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29657&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29657&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29657&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29657&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29657&r=float

Reply via email to