-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix for PHP warning "is_file(): open_basedir restriction in effect", round 2 #48
Conversation
This reverts commit d234b8e.
Question: how come the Can you explain how is your setup? It is a bit strange it fails like that when trying to open a file that should be child of the root app. |
Let's back up a bit here. I think there is another issue that is the root cause here. The fact that this file is outside the basedir restriction is more the problem. This
This is not right for you, not sure why that would be. Can you debug in your system and see what |
|
Then it should be like this: /** @var \DirectoryIterator $plugin */
foreach ($iterator as $plugin) {
if (!$iterator->isFile() || $iterator->isDot()) continue;
$name = $plugin->getBasename();
$file = $plugin->getPathname() . DS . $name . YAML_EXT;
$modified = filemtime($file);
$plugins["plugins/{$name}"] = $modified;
} Since the Can you try? |
I think that the @w00fz code should solve the case of this |
Yeah you are right. I also have a typo up there in the check for /** @var \DirectoryIterator $plugin */
foreach ($iterator as $plugin) {
if ($iterator->isFile() || $iterator->isDot()) continue;
$name = $plugin->getBasename();
$file = $plugin->getPathname() . DS . $name . YAML_EXT;
if (!file_exists($file)) continue;
$modified = filemtime($file);
$plugins["plugins/{$name}"] = $modified;
} |
Yes the second snippet is OK, it var_dumped only non-dot directories and thus triggered no warning. |
Ok that's cool. I just realized we can just revert that |
Well, I benchmarked it now and file_exists() has been always slightly faster... $glob=glob(__DIR__ . '/*');
$t = microtime(true);
for ($i = 0; $i < 10000; $i++) {
foreach ($glob as $file) {
file_exists($file);
}
}
$t=microtime(true)-$t;
echo round($t*1000,2);
echo "\n";
$t = microtime(true);
for ($i = 0; $i < 10000; $i++) {
foreach ($glob as $file) {
is_file($file);
}
}
$t=microtime(true)-$t;
echo round($t*1000,2);
|
most probably because it only checks if inode exists and doesnt look at it's content. |
You need to use But the thing is |
Right, now its
So should I commit it to this branch or will you create a new one? |
Commit in here and we can merge. |
Committed |
fix for PHP warning "is_file(): open_basedir restriction in effect", round 2
Cheers! |
This reverts commit d234b8e in PR #47 and returns back the is_dir() check.
I was working with too many hosts simultaneously and checked the file_exists() method on a host that worked perfectly even before the fix and as I updated the files on the problematic host the problems returned and the warning message changed to:
I'm sorry for this and have triple-checked that this code really finally fixes the issue.