php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10490 xslt_process() generates fatal error
Submitted: 2001-04-25 10:32 UTC Modified: 2001-04-26 09:59 UTC
From: svein-roar dot nilsen at statkart dot no Assigned:
Status: Closed Package: Sablotron XSL
PHP Version: 4.0 Latest CVS (25/04/2001) OS: Debian Unstable
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: svein-roar dot nilsen at statkart dot no
New email:
PHP Version: OS:

 

 [2001-04-25 10:32 UTC] svein-roar dot nilsen at statkart dot no
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-26 09:59 UTC] sterling@php.net
If you really want to catch the error you can use the
xslt_set_error_handler() function.  Not a bug (already had
this conversation with a user, check the closed bug reports
to view it).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC