Req #70507 [Opn]: Combination of is_file() + include (e.g. "include_if_exists")

From: Date: Wed, 16 Sep 2015 01:44:29 +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-196029@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: > 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. Previous Comments: ------------------------------------------------------------------------ [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? ------------------------------------------------------------------------ [2015-09-15 20:16:55] andreas at dqxtech dot net > If you're concerned about how include/etc. do their own file lookups then wouldn't it > be better to fix that specifically? PHP has a file stat cache already where the result of the first > lookup is reused throughout execution (unless the cache gets cleared). I did some quick strace tests > and it doesn't look like the functions are using it... Sure, sounds a good idea! I'm afraid I'm not going to be of much help here though. Never touched the internals stuff. ------------------------------------------------------------------------ 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

« previous php.bugs (#196029) next »