Affected page
From manual page: https://php.net/function.opcache-invalidate
Issue description
In manual page for opcache_invalidate() there's mentioned, that "This function only invalidates in-memory cache and not file cache.".
But as I tried to verify this (PHP 8.3.32 - to evaluate, if I can enable additional file_cache and what I would have to be careful about), I realized, that calling the function indeed removed the compiled file in the file_cache directory.
I even looked into the php-src code for opcache and in https://github.com/php/php-src/blame/master/ext/opcache/ZendAccelerator.c lines 1445-1448 (status today - commit c191020) a file cache invalidate is being called that deletes the file. This seems to have been implemented together with file_cache 11 years ago.
Steps to reproduce
- Create two PHP files (e.g. optest.php and optest2.php - optest2 only defines a variable and optest accesses it)
- include optest2.php in optest.php and open in browser
- verify that binary for optest2.php is being created
- call
opcache_invalidate("optest2.php"); - e.g. in optest.php
- open again
- verify that binary for optest2.php was deleted
Suggested fix
Check actual behaviour and intended behaviour again and maybe remove sentence "This function only invalidates in-memory cache and not file cache." from manual page of this function.
Affected page
From manual page: https://php.net/function.opcache-invalidate
Issue description
In manual page for
opcache_invalidate()there's mentioned, that "This function only invalidates in-memory cache and not file cache.".But as I tried to verify this (PHP 8.3.32 - to evaluate, if I can enable additional file_cache and what I would have to be careful about), I realized, that calling the function indeed removed the compiled file in the file_cache directory.
I even looked into the php-src code for opcache and in https://github.com/php/php-src/blame/master/ext/opcache/ZendAccelerator.c lines 1445-1448 (status today - commit c191020) a file cache invalidate is being called that deletes the file. This seems to have been implemented together with file_cache 11 years ago.
Steps to reproduce
opcache_invalidate("optest2.php");- e.g. in optest.phpSuggested fix
Check actual behaviour and intended behaviour again and maybe remove sentence "This function only invalidates in-memory cache and not file cache." from manual page of this function.