Bug #10490: xslt_process() generates fatal error
| From: | svein-roar dot nilsen at statkart dot no | Date: | Wed, 25 Apr 2001 14:32:20 +0000 |
| Subject: | Bug #10490: xslt_process() generates fatal error | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-52382@lists.php.net to get a copy of this message | ||
From: svein-roar.nilsen@statkart.no
Operating system: Debian Unstable
PHP version: 4.0 Latest CVS (25/04/2001)
PHP Bug Type: Sablotron XSL
Bug description: xslt_process() generates fatal error
Well, not actually the latest CVS, but RC6-2 from Debian Unstable, which should be close enough...
At http://www.php.net/manual/en/function.xslt-process.php
there is an example program. When I use it as is, it works all right and produces a nice table. Here
is a short section of the code:
-----
[...]
if (xslt_process($xslData, $xmlData, $result)) {
[...]
} else {
echo "There was an error that occurred in the XSL transformation...\n";
echo "\tError number: " . xslt_errno() . "\n";
echo "\tError string: " . xslt_error() . "\n";
exit;
}
?>
-----
This is quite similar to what I am trying. If you now corrupts the xmlData variable, e.g. by
changing <article> to <rticl> without changing the closing tag, you will get an error
message saying
<br>
<b>Fatal error</b>: XML parser error 7: mismatched tag in
<b>/var/www/test.php</b> on line <b>40</b><br>
As you can see here, xslt_process() dies with a fatal error and the program is terminated, and we
never get to testing the return value. The next problem, is that since the error is
"fatal", it is also not possible to use set_error_handler() to catch the error.
Of course it can be discussed wether this is a bug or not, but when a function is documented to
return false on error, I would not expect it to lay down and die. And since it should not corrupt
the PHP internals in any way, I would at least expect to be able to handle it with
set_error_handler().
Svein Roar Nilsen
Norwegian Hydrographic Services
--
Edit Bug report at: http://bugs.php.net/?id=10490&edit=1