Req #70507 [Opn]: Combination of is_file() + include (e.g. "include_if_exists")
| From: | yohgaki@php.net | Date: | Wed, 16 Sep 2015 01:45:25 +0000 |
| Subject: | Req #70507 [Opn]: Combination of is_file() + include (e.g. "include_if_exists") | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196030@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70507&edit=1
ID: 70507
Updated by: yohgaki@php.net
Reported by: andreas at dqxtech dot net
Summary: Combination of is_file() + include (e.g.
"include_if_exists")
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 7.0.0RC2
Block user comment: N
Private report: N
New Comment:
if (@include($script)) {
should be
if (!@include($script)) {
Previous Comments:
------------------------------------------------------------------------
[2015-09-16 01:44:28] yohgaki@php.net
> Someone will tell me I shouldn't. I am sure of that :)
Right. Generally speaking, it is advised.
"@" operator is like "goto" for me. Sloppy use of "goto" ruins code,
but decent use of "goto" achieves clean and robust code.
if (@include($script)) {
// ERROR!!
}
is good use case of "@" IMO.
------------------------------------------------------------------------
[2015-09-15 22:10:02] andreas at dqxtech dot net
> If you guys agree this is the case then fine..
At least requinix above says that not all functions are using the file exists cache.
> I recall measuring a slight difference there. Not a big worry, but relevant enough for the
> "fastest classloader in town" game..
And I imagine filesystem performance can be different depending on the environment.
------------------------------------------------------------------------
[2015-09-15 22:08:15] andreas at dqxtech dot net
> I think opcache is already caching file existence checks, so doing file_exists (or is_file)
> should be very cheap once the file is in cache.
If you guys agree this is the case then fine..
I recall measuring a slight difference there. Not a big worry, but relevant enough for the
"fastest classloader in town" game..
> Can't you just do @include?
Someone will tell me I shouldn't. I am sure of that :)
------------------------------------------------------------------------
[2015-09-15 21:39:13] stas@php.net
Can't you just do @include?
I think opcache is already caching file existence checks, so doing file_exists (or is_file) should
be very cheap once the file is in cache.
------------------------------------------------------------------------
[2015-09-15 20:18:38] andreas at dqxtech dot net
Does this cache also cover file permissions?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=70507
--
Edit this bug report at https://bugs.php.net/bug.php?id=70507&edit=1