You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could imagine this is the expected behavior but docs should be updated then. :) There are no restrictions defined in https://www.php.net/manual/en/opcache.preloading.php BTW, the opcache_enabled shown as false for var_dump(opcache_get_status(false));.
PHP Version
8.1.16
Operating System
Docker image: php:8.1-fpm-bullseye
The text was updated successfully, but these errors were encountered:
I tried tackling this, but it's more complicated than I thought. The constants (and stdin/stdout/stderr stream configuration) happen in cli_register_file_handles() which is called from do_cli(). But the preloaded script gets executed before that happens, in php_module_startup() which is called from php_cli_startup(). I tried to create a fake module that calls cli_register_file_handles() that runs before opcache's startup, but that crashes because we need zend_activate() to have been called for the open files and resources lists.
So in short this means that only for the lifetime of the main script the cli_register_file_handles() function is called. This also means that the following gives strange results:
Put the echo in the preload file and you get a "bad file descriptor" warning, and put the fopen-fwrite-fclose in the index file and you get "hello" and "hi".
Description
As of https://www.php.net/manual/en/features.commandline.io-streams.php , there should be constants defined in CLI.
Added the following to
preload.ini
:The following code wrote to
preload.php
:Resulted in this output:
But I expected this output instead:
I could imagine this is the expected behavior but docs should be updated then. :) There are no restrictions defined in https://www.php.net/manual/en/opcache.preloading.php BTW, the
opcache_enabled
shown asfalse
forvar_dump(opcache_get_status(false));
.PHP Version
8.1.16
Operating System
Docker image: php:8.1-fpm-bullseye
The text was updated successfully, but these errors were encountered: