[php-src] Issue #18840: opcache.file_cache_only seems to disable opcache

From: Date: Thu, 12 Jun 2025 11:41:38 +0000
Subject: [php-src] Issue #18840: opcache.file_cache_only seems to disable opcache
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250251@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/18840 Author: homersimpsons ### Description The following code: ```sh ❯ mkdir -p /tmp/.opcache && php -d opcache.enable_cli=1 -d opcache.file_cache=/tmp/.opcache -d opcache.file_cache_only=1 -r "var_dump(opcache_get_status());" ``` Resulted in this output: ```log array(3) { ["opcache_enabled"]=> bool(false) ["file_cache"]=> string(13) "/tmp/.opcache" // ... } ``` But I expected this output instead: ``` array(10) { ["opcache_enabled"]=> bool(true) ["file_cache"]=> string(13) "/tmp/.opcache" // ... } ``` Note that without opcache.file_cache_only the output is correct: ```sh ❯ mkdir -p /tmp/.opcache && php -d opcache.enable_cli=1 -d opcache.file_cache=/tmp/.opcache -r "var_dump(opcache_get_status());" array(10) { ["opcache_enabled"]=> bool(true) ["file_cache"]=> string(13) "/tmp/.opcache" // ... } ``` ### Context Overall context: I have a short-living container that runs a script (that is doing computations) and I wanted to experiment warming up opcache before so I could speed up the script execution. I tried the following setup: ```php <?php // opcache_compile.php // This is assuming composer install --classmap-authoritative declare(strict_types=1); use Composer\Autoload\ClassLoader; $loader = include 'vendor/autoload.php'; assert($loader instanceof ClassLoader); foreach ($loader->getClassMap() as $file) { opcache_compile_file($file); } ``` ```Dockerfile # Dockerfile FROM php:8.4-cli-alpine COPY --from=builder /opt/app /opt/app RUN docker-php-ext-install opcache \ && mkdir /opt/app/.opcache \ && /usr/local/bin/php -d opcache.enable_cli=1 -d opcache.file_cache=/opt/app/.opcache -d opcache.file_cache_only=1 /opt/app/opcache_compile.php ENTRYPOINT ["/opt/app/bin/run.sh"] ``` With the expectation of running it with ```sh docker run --rm app /usr/local/bin/php -d opcache.enable_cli=1 -d opcache.file_cache=/opt/app/.opcache -d opcache.file_cache_only=1 /opt/app/app.php ``` ### PHP Version ```plain PHP 8.3.6 (cli) (built: Mar 19 2025 10:08:38) (NTS) Copyright (c) The PHP Group Zend Engine v4.3.6, Copyright (c) Zend Technologies with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies ``` ### Operating System Ubuntu 24.04

« previous php.bugs (#250251) next »