Skip to content
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

Check whether opcache is restricted before attempting to invalidate #351

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Stash/Driver/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,18 @@ public function storeData($key, $data, $expiration)
// This fix immediately invalidates that opcode cache after a file is written,
// so that future includes are not using the stale opcode cached file.
if (function_exists('opcache_invalidate')) {
opcache_invalidate($path, true);
$invalidate = true;

if ($restrictedDirectory = ini_get('opcache.restrict_api')) {
if (strpos(__FILE__, $restrictedDirectory) !== 0) {
// Opcache is restricted and likely to throw an error, let's just not invalidate
$invalidate = false;
}
}

if ($invalidate) {
@opcache_invalidate($path, true);
}
}

return false !== $result;
Expand Down