ID:               48511
 Comment by:       michael202 at gmx dot de
 Reported By:      geoffers+phpbugs at gmail dot com
 Status:           Assigned
 Bug Type:         XML Writer
 Operating System: Mac OS 10.5.7
 PHP Version:      5.3CVS-2009-06-09 (CVS)
 Assigned To:      rrichards
 New Comment:

I have a similar problem:

libxml_get_errors() is empty after loading a faulty XML with
simplexml_load_file() BUT libxml_get_last_error() contains the last
error:
var_dump(libxml_get_errors()) ----> array(0) { }
var_dump(libxml_get_last_error()) ----> object(LibXMLError)#11 ....



"solution" is to use libxml_use_internal_errors:

libxml_clear_errors(); // otherwise you also get all of the old errors
libxml_use_internal_errors(true);

other advantage is the you do not get any PHP Warning outputs and you
can call simplexml_load_file without the @-operator


strange though:
simplexml_load_file() displays the correct error position in the "PHP
Warning" BUT libxml_get_errors() does not contain it.


Previous Comments:
------------------------------------------------------------------------

[2009-06-09 17:49:07] geoffers+phpbugs at gmail dot com

Description:
------------
I would expect the last member of the array returned by
libxml_get_errors() to be equal to libxml_get_last_error(), but the
former returns an empty array while the latter returns the expected
error object.

Reproduce code:
---------------
<?php

$foo = new XMLWriter();
$foo->openMemory();
$foo->startElement("\xEF\xBF\xBF");
var_dump(libxml_get_last_error());
var_dump(libxml_get_errors());
var_dump(libxml_get_last_error() == end(libxml_get_errors()));

Expected result:
----------------
Warning: XMLWriter::startElement(): Char 0xFFFF out of allowed range in
/Users/gsnedders/Desktop/test.php on line 5

Warning: XMLWriter::startElement(): Invalid Element Name in
/Users/gsnedders/Desktop/test.php on line 5
object(LibXMLError)#2 (6) {
  ["level"]=>
  int(3)
  ["code"]=>
  int(9)
  ["column"]=>
  int(0)
  ["message"]=>
  string(33) "Char 0xFFFF out of allowed range
"
  ["file"]=>
  string(0) ""
  ["line"]=>
  int(0)
}
array(1) {
  [0]=>
  object(LibXMLError)#2 (6) {
    ["level"]=>
    int(3)
    ["code"]=>
    int(9)
    ["column"]=>
    int(0)
    ["message"]=>
    string(33) "Char 0xFFFF out of allowed range
"
    ["file"]=>
    string(0) ""
    ["line"]=>
    int(0)
  }
}
bool(true)

Actual result:
--------------
Warning: XMLWriter::startElement(): Char 0xFFFF out of allowed range in
/Users/gsnedders/Desktop/test.php on line 5

Warning: XMLWriter::startElement(): Invalid Element Name in
/Users/gsnedders/Desktop/test.php on line 5
object(LibXMLError)#2 (6) {
  ["level"]=>
  int(3)
  ["code"]=>
  int(9)
  ["column"]=>
  int(0)
  ["message"]=>
  string(33) "Char 0xFFFF out of allowed range
"
  ["file"]=>
  string(0) ""
  ["line"]=>
  int(0)
}
array(0) {
}
bool(false)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48511&edit=1

Reply via email to