Skip to content

function.opcache-invalidate: Is "This function only invalidates in-memory cache and not file cache." still correct (or was it ever)? #5696

Description

@dev-maniac

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

  1. Create two PHP files (e.g. optest.php and optest2.php - optest2 only defines a variable and optest accesses it)
  2. include optest2.php in optest.php and open in browser
  3. verify that binary for optest2.php is being created
  4. call opcache_invalidate("optest2.php"); - e.g. in optest.php
  5. open again
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDocumentation contains incorrect information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions