Re: Don't silence fatal errors

From: Date: Thu, 07 Feb 2019 09:01:01 +0000
Subject: Re: Don't silence fatal errors
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-104274@lists.php.net to get a copy of this message
> > That is one the cases I meant. Also this is a bug in the user code. I can > imagine doing it on purpose for performance reasons (if the file is > created/deleted by other apps) tho'. > flock is what should be used here. flock doesn't protect from other failures, such as a fread()ing a file located on NFS. As it stands now, @ may still useful to mute warnings and throw exceptions instead. The other solution today is to set up a temporary error handler before calling the native function, and restore the previous error handler right after, such as here <https://github.com/brick/std/blob/master/src/Internal/ErrorCatcher.php>. This allows to get the error message, but might incur a small performance penalty. IMO, @ can be safely removed the day PHP converts current warnings to exceptions. On Thu, 7 Feb 2019 at 02:32, Pierre Joye <pierre.php@gmail.com> wrote: > On Thu, Feb 7, 2019, 8:07 AM Girgias <george.banyard@gmail.com wrote: > > > > > The most common case which comes to mind is to suppress erros while file > > reading. > > Because even if you check a file exists it could be deleted inbetween the > > check and the > > read command. As you can see this is even written in the documentation > [1] > > > > Best regards > > > > George Peter Banyard > > > > [1] https://secure.php.net/manual/en/function.fopen.php > > > > That is one the cases I meant. Also this is a bug in the user code. I can > imagine doing it on purpose for performance reasons (if the file is > created/deleted by other apps) tho'. > flock is what should be used here. > > best, > Pierre > > > > > >

« previous php.internals (#104274) next »