We've defined a custom libxml2 error handler, php_libxml_error_handler(), that makes error messages go through php_error() instead of printing to stderr.
Unfortunately, libxml2 doesn't make one call to the error function for each error. Sometimes it seems to do it once per character. Unfortunately, this makes the error log look crazy. For instance: $s = domDocument::load('http://www.php.net/news.rss'); $xpath = new domXpath($s); $nodes = $xpath->query('//rss:title'); Gives: PHP Warning: XPath error Undefined namespace prefix in /home/adam/xml-test.php on line 7 PHP Warning: / in /home/adam/xml-test.php on line 7 PHP Warning: / in /home/adam/xml-test.php on line 7 PHP Warning: r in /home/adam/xml-test.php on line 7 PHP Warning: s in /home/adam/xml-test.php on line 7 PHP Warning: s in /home/adam/xml-test.php on line 7 PHP Warning: : in /home/adam/xml-test.php on line 7 PHP Warning: t in /home/adam/xml-test.php on line 7 PHP Warning: i in /home/adam/xml-test.php on line 7 PHP Warning: t in /home/adam/xml-test.php on line 7 PHP Warning: l in /home/adam/xml-test.php on line 7 PHP Warning: e in /home/adam/xml-test.php on line 7 ... (and about 12 more lines after this.) It should look something like: PHP Warning: XPath error Undefined namespace prefix in /home/adam/xml-test.php on line 7 PHP Warning: //rss:title in /home/adam/xml-test.php on line 7 PHP Warning: ^ in /home/adam/xml-test.php on line 7 Reviewing libxml2 error messages, I propose we create a libxml2 error buffer that only gets flushed when libxml2 sends us a string that ends in "\n". Otherwise, we just append the new error to the buffer. I have a patch that does this. Unfortunately, I'm unsure of the best way to maintain the buffer between calls. I'm pretty sure I'm not allowed to just declare it "static" within php_libxml_error_handler(). My current patch makes it a global variable, which seems just as bad. I'm not worried too much about concurrency issues because if libxml2 doesn't make atomic error calls, we can't fix it on our end. However, it would be nice if each extension / instance that uses this error function maintain its own buffer, or is that not really an issue? The patch is up at: http://www.trachtenberg.com/patches/php_libxml_error_handler.txt -adam -- [EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php