-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Log error cause when opcache cannot write to file cache #9258
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--TEST-- | ||
File cache error 001 | ||
--EXTENSIONS-- | ||
opcache | ||
posix | ||
pcntl | ||
--INI-- | ||
opcache.enable_cli=1 | ||
opcache.file_cache={TMP} | ||
opcache.log_verbosity_level=2 | ||
--SKIPIF-- | ||
<?php | ||
posix_setrlimit(POSIX_RLIMIT_FSIZE, 1, 1) || die('skip Test requires setrlimit(RLIMIT_FSIZE) to work'); | ||
ini_parse_quantity(ini_get('opcache.jit_buffer_size')) === 0 || die('skip File cache is disabled when JIT is on'); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
// Create new file to ensure that it's not cached accross test runs | ||
$file = tempnam(sys_get_temp_dir(), 'file_cache_error'); | ||
register_shutdown_function(function () use ($file) { | ||
unlink($file); | ||
}); | ||
file_put_contents($file, '<?php echo "OK";'); | ||
touch($file, time() - 3600); | ||
|
||
// Some systems will raise SIGXFSZ when RLIMIT_FSIZE is exceeded | ||
if (defined('SIGXFSZ')) { | ||
pcntl_signal(SIGXFSZ, SIG_IGN); | ||
} | ||
|
||
// Should cause writing to cache file to fail | ||
var_dump(posix_setrlimit(POSIX_RLIMIT_FSIZE, 1, 1)); | ||
|
||
// Will attempt to write to cache file, and fail | ||
require $file; | ||
?> | ||
--EXPECTF-- | ||
bool(true) | ||
%sWarning opcache cannot write to file %s: %s | ||
|
||
OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I, personally, dislike this pattern (regardless of whether
||
oror
is used), and would go with a single lineif
statement.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. Although the style guide says you should add braces to
if
statements. (Although granted that's for C)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'd rather change the style guide, than to find some loopholes. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I don't find single line
if
s to be an issue. IMO the only justified concern is:Most of our macros guard against this with a
do {} while(0);
loop though.