RE: [SMARTY-DEV] improper check for existance of a file when incl uding PHP files

From: Date: Wed, 11 Dec 2002 19:11:18 +0000
Subject: RE: [SMARTY-DEV] improper check for existance of a file when incl uding PHP files
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-407@lists.php.net to get a copy of this message
Are you sure? That would cause some real headaches, especially if a files state changes between stats. I don't think PHP attempts any caching. On Wed, 2002-12-11 at 12:09, Lee Coltrane wrote: > I think that php caches file stats, so, I believe that doing a file_exists > followed immediately by an is_file is not actually as time-consuming as it > seems like it would be. > > ...I could be wrong, however. > > Anyway, it's a personal preference, but I feel like the '@' operator is kind > of a kludge regardless of how/when it is used. Of course, given the chance, > I would have made is_file return false when the file doesn't exist, rather > than triggering a warning, but we have no control over that one. :-) > > IMHO, of course. > -Lee > > > -----Original Message----- > > From: Monte Ohrt [mailto:monte@ispi.net] > > Sent: Wednesday, December 11, 2002 12:35 PM > > To: Yuri Weseman > > Cc: smarty-dev@lists.php.net > > Subject: Re: [SMARTY-DEV] improper check for existance of a file when > > including PHP files > > > > > > This method takes two file stats to perform the same operation instead > > of one. That is why one was used with an "@" to suppress it. > > > > I believe there is a way to tell if an error was suppressed > > with an "@" > > or not, you should consider that in your error handler. > > > > Monte > > > > On Wed, 2002-12-11 at 04:19, Yuri Weseman wrote: > > > 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 > > > > > > > > ______________________________________________________________________ > > > > > > -- > > > Smarty Development Mailing List (http://smarty.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > > Monte Ohrt <monte@ispi.net> > > > > > > -- > > Smarty Development Mailing List (http://smarty.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Monte Ohrt <monte@ispi.net>

« previous php.smarty.dev (#407) next »