-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
opcache_is_script_cached_in_file_cache(string $filename) #16979
Open
iamacarpet
wants to merge
16
commits into
php:master
Choose a base branch
from
iamacarpet:opcache/opcache_is_script_cached_file
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+368
−5
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
200193b
opcache_is_script_cached: file_cache option
iamacarpet 798a07d
opcache_is_script_cached: file_cache: test
iamacarpet 824e638
fix when file_cache_read_only
iamacarpet 30641d6
remove file_cache_only
iamacarpet 283844e
switch to zend_file_cache_script_validate(...)
iamacarpet 8cc7293
fix build
iamacarpet fd93557
switch to opcache_is_script_cached_in_file_cache(...)
iamacarpet 7e23285
remove double close(fd)
iamacarpet 906b92d
zend_file_cache_open with struct
iamacarpet 1cdf3fa
fix build
iamacarpet f620d9c
Unit Tests for GH-16551
iamacarpet 6df1562
fix for file_cache_only
iamacarpet e282578
probe ARM test failure
iamacarpet 17edbe6
remove unnecessary tests
iamacarpet cd0177f
Merge remote-tracking branch 'origin/master' into opcache/opcache_is_…
iamacarpet 7cff70a
switch to validate_only method
iamacarpet 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 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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-- | ||
GH-16551: opcache file cache read only: generate file cache | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.jit=disable | ||
opcache.jit_buffer_size=0 | ||
opcache.file_cache="{TMP}" | ||
--EXTENSIONS-- | ||
opcache | ||
--CONFLICTS-- | ||
opcache_file_cache | ||
--FILE-- | ||
<?php | ||
|
||
$file = __DIR__ . '/gh16551_998.inc'; | ||
$uncached_file = __DIR__ . '/gh16551_999.inc'; | ||
|
||
opcache_compile_file($file); | ||
|
||
var_dump( | ||
opcache_is_script_cached($file) | ||
); | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($file) | ||
); | ||
|
||
var_dump( | ||
opcache_is_script_cached($uncached_file) | ||
); | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($uncached_file) | ||
); | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(true) | ||
bool(false) | ||
bool(false) |
This file contains 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,37 @@ | ||
--TEST-- | ||
GH-16551: opcache file cache read only: read file cache | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.jit=disable | ||
opcache.jit_buffer_size=0 | ||
opcache.file_cache="{TMP}" | ||
opcache.file_cache_read_only=1 | ||
--EXTENSIONS-- | ||
opcache | ||
--CONFLICTS-- | ||
opcache_file_cache | ||
--FILE-- | ||
<?php | ||
|
||
$file = __DIR__ . '/gh16551_998.inc'; | ||
$uncached_file = __DIR__ . '/gh16551_999.inc'; | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($file) | ||
); | ||
|
||
require $file; | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($uncached_file) | ||
); | ||
|
||
require $uncached_file; | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
9 | ||
bool(false) | ||
8 |
This file contains 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,41 @@ | ||
--TEST-- | ||
GH-16551: opcache file cache read only: read file cache with limited checks | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.jit=disable | ||
opcache.jit_buffer_size=0 | ||
opcache.file_cache="{TMP}" | ||
opcache.file_cache_read_only=1 | ||
opcache.revalidate_freq=0 | ||
opcache.enable_file_override=true | ||
opcache.validate_timestamps=false | ||
opcache.file_cache_consistency_checks=false | ||
--EXTENSIONS-- | ||
opcache | ||
--CONFLICTS-- | ||
opcache_file_cache | ||
--FILE-- | ||
<?php | ||
|
||
$file = __DIR__ . '/gh16551_998.inc'; | ||
$uncached_file = __DIR__ . '/gh16551_999.inc'; | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($file) | ||
); | ||
|
||
require $file; | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($uncached_file) | ||
); | ||
|
||
require $uncached_file; | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
9 | ||
bool(false) | ||
8 |
This file contains 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,36 @@ | ||
--TEST-- | ||
GH-16551: opcache file cache read only: ensure we can't invalidate | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.jit=disable | ||
opcache.jit_buffer_size=0 | ||
opcache.file_cache="{TMP}" | ||
opcache.file_cache_read_only=1 | ||
--EXTENSIONS-- | ||
opcache | ||
--CONFLICTS-- | ||
opcache_file_cache | ||
--FILE-- | ||
<?php | ||
|
||
$file = __DIR__ . '/gh16551_998.inc'; | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($file) | ||
); | ||
|
||
// invalidate SHM, but silently ignore file cache. | ||
opcache_invalidate($file, true); | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($file) | ||
); | ||
|
||
require $file; | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(true) | ||
9 |
This file contains 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,32 @@ | ||
--TEST-- | ||
GH-16551: opcache file cache read only: ensure cache files aren't created | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.jit=disable | ||
opcache.jit_buffer_size=0 | ||
opcache.file_cache="{TMP}" | ||
opcache.file_cache_read_only=1 | ||
--EXTENSIONS-- | ||
opcache | ||
--CONFLICTS-- | ||
opcache_file_cache | ||
--FILE-- | ||
<?php | ||
|
||
$uncached_file = __DIR__ . '/gh16551_999.inc'; | ||
|
||
opcache_compile_file($uncached_file); | ||
|
||
var_dump( | ||
opcache_is_script_cached($uncached_file) | ||
); | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($uncached_file) | ||
); | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(false) |
This file contains 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,70 @@ | ||
--TEST-- | ||
GH-16551: opcache file cache read only: double check file_cache_only | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.jit=disable | ||
opcache.jit_buffer_size=0 | ||
opcache.file_cache="{PWD}" | ||
opcache.file_cache_only=1 | ||
--EXTENSIONS-- | ||
opcache | ||
--CONFLICTS-- | ||
opcache_file_cache | ||
--FILE-- | ||
<?php | ||
|
||
$uncached_file = __DIR__ . '/gh16551_999.inc'; | ||
|
||
var_dump( | ||
opcache_is_script_cached($uncached_file) | ||
); | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache($uncached_file) | ||
); | ||
|
||
opcache_compile_file($uncached_file); | ||
|
||
var_dump( | ||
opcache_is_script_cached($uncached_file) | ||
); | ||
|
||
// check the cache file itself exists... | ||
if (substr(PHP_OS, 0, 3) !== 'WIN') { | ||
$pattern = __DIR__ . '/*/' . __DIR__ . '/*16551_999.inc.bin'; | ||
} else { | ||
$pattern = __DIR__ . '/*/*/' . str_replace(':', '', __DIR__) . '/*16551_999.inc.bin'; | ||
} | ||
foreach (glob($pattern) as $p) { | ||
var_dump($p !== false); | ||
} | ||
|
||
// check it is reported as existing... | ||
var_dump( | ||
opcache_is_script_cached_in_file_cache($uncached_file) | ||
); | ||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
if (substr(PHP_OS, 0, 3) !== 'WIN') { | ||
$pattern = __DIR__ . '/*/' . __DIR__ . '/*16551*.bin'; | ||
} else { | ||
$pattern = __DIR__ . '/*/*/' . str_replace(':', '', __DIR__) . '/*16551*.bin'; | ||
} | ||
foreach (glob($pattern) as $p) { | ||
unlink($p); | ||
$p = dirname($p); | ||
while(strlen($p) > strlen(__DIR__)) { | ||
@rmdir($p); | ||
$p = dirname($p); | ||
} | ||
} | ||
?> | ||
--EXPECT-- | ||
bool(false) | ||
bool(false) | ||
bool(false) | ||
bool(true) | ||
bool(true) |
This file contains 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,5 @@ | ||
<?php | ||
|
||
$a = 4+5; | ||
|
||
echo $a . "\n"; |
This file contains 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,5 @@ | ||
<?php | ||
|
||
$a = 3+5; | ||
|
||
echo $a . "\n"; |
This file contains 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,27 @@ | ||
--TEST-- | ||
GH-16979: opcache_is_script_cached support file_cache argument | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.jit=disable | ||
opcache.jit_buffer_size=0 | ||
opcache.file_cache="{TMP}" | ||
--EXTENSIONS-- | ||
opcache | ||
--FILE-- | ||
<?php | ||
|
||
opcache_compile_file(__FILE__); | ||
|
||
var_dump( | ||
opcache_is_script_cached(__FILE__) | ||
); | ||
|
||
var_dump( | ||
opcache_is_script_cached_in_file_cache(__FILE__) | ||
); | ||
|
||
?> | ||
--EXPECT-- | ||
bool(true) | ||
bool(true) |
Oops, something went wrong.
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.
These tests look problematic to me. They will fail on first execution (confirmed locally).
I don't understand why they don't fail on CI. It's also possible they are order dependent, i.e. one job will prime the cache, another will check that the cache is not primed.
One solution might be to set
opcache.file_cache
to some sub-directory and clean it in the--CLEAN--
section to ensure a consistent state.