improper check for existance of a file when including PHP files
| From: | Yuri Weseman | Date: | Wed, 11 Dec 2002 10:19:53 +0000 |
| Subject: | improper check for existance of a file when including PHP files | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-400@lists.php.net to get a copy of this message | ||
Hi everyone,
Recently we installed a custom error handler for PHP, that shows a nifty
error screen when critical errors occur in PHP scripts. Also, the script
sends mails when not so critical errors have occurred. Now I've noticed that
Smarty generates an error in line 866 of Smarty.class.php (version 2.3.0).
In get_php_resource a check is done to see if the resource exists by using
is_file. To suppress any errors an @ sign is placed in front of it. But
still this does trigger our error handler and thus generates mails.
A more clean approach would be to use file_exists first.
Line 866 is now:
if (is_file($resource_name)) {
I suggest it will be:
if (file_exists($resource_name) && is_file($resource_name)) {
Included is a diff file so that Smarty can be patched.
Greetings,
Yuri Weseman
866c866 < if (file_exists($resource_name) && is_file($resource_name)) { --- > if(@is_file($resource_name)) {
866c866 < if (file_exists($resource_name) && is_file($resource_name)) { --- > if(@is_file($resource_name)) {