|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-01-25 20:58 UTC] post at minhost dot no
[2019-01-28 11:09 UTC] anders dot henke at 1und1 dot de
[2019-01-28 11:27 UTC] spam2 at rhsoft dot net
[2019-08-17 01:23 UTC] rolmos at endertech dot com
[2021-07-08 14:06 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2021-07-08 14:06 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 08:00:01 2025 UTC |
Description: ------------ From PHP 7.0 on, PHP's opcache includes a file-cache as an optional overflow mechanism and optionally as the only kind of opcache storage (opcache.file_cache_only=1). The later is interesting in CGI-mode, where shared memory does not survive a single PHP run. PHP's opcache does provide a function opcache_reset() to "reset the entire opcode cache. After calling opcache_reset(), all scripts will be reloaded and reparsed the next time they are hit.". This function may be called explicitely (e.g. during software deployment) to clear any caches and remove accumulated stale cache objects who are no longer being accessed. Whenever a file-based opcache storage is being added to Opcache, opcache_reset() does only reset a shared memory-based opcache, but does not reset any file-based opcache storage. In a performance-optimized setup, a user may use shared-memory-based opcache with file-based opcache storage as a fallback, disable automatic revalidation and manually perform opcache_reset() during the deployment process. In such a situation, opcache_reset() returns true and restarts the shared memory-based storage, but does not remove any objects from the file-based opcache storage. This possibly might result in running code from outdated cache objects. Test script: --------------- php.ini: ---cut zend_extension=opcache.so; opcache.enable=1; opcache.revalidate_freq=180; opcache.validate_timestamps=2; opcache.file_cache=/var/tmp/opcache; opcache.file_cache_only=1; ---cut clear.php: ---cut <pre> <?php echo "**Before Clear Opcache:\n"; system('ls -lRt ' . ini_get('opcache.file_cache')); echo "\n\n**Clear Opcache: "; var_dump(opcache_reset()); echo "\n"; echo "**After Clear Opcache:\n"; system('ls -lRt ' . ini_get('opcache.file_cache')); ?> </pre> ---cut Expected result: ---------------- http://php.net/manual/en/function.opcache-reset.php states "This function resets the entire opcode cache. After calling opcache_reset(), all scripts will be reloaded and reparsed the next time they are hit. According to my reading, "reset the entire opcache" does also include the file-based opcache. In my test script above, the actual content "before" and "after" opcache_reset() stays the same. Actual result: -------------- opcache_reset() does not affect a file-based opcache at all and only restarts the shared-memory-based opcache. In a file_cache_only-configuration, opcache_reset() does not reset the file-based opcache, but returns "false", which should only happen when opcache is disabled. According to phpinfo(), opcache is enabled and running. In a overflow/fallback configuration, opcache_reset() does return true, but will only restart the shared memory storage and not reset any file-based opcache storage. Depending on the overall configuration, this might result in running cached but outdated code. Such an issue has also been reported in bug #75670.