-
Notifications
You must be signed in to change notification settings - Fork 7.8k
OPcache bypasses the user-defined error handler for deprecations #17422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
OPcache explicitly clears the user error handler in: php-src/ext/opcache/ZendAccelerator.c Line 1806 in d8d1cb4
before compiling the file. This is done since the first version of the open source OPcache, so it's not clear to me, why it does this. |
I have same problem on php version 8.4.1 |
Works correctly for me (Rocky Linux) |
Bug is still present on PHP 8.4.3. |
I stand corrected, this is caused by
|
…ile()` The logic to disable userland error handlers existed since the first commit including OPcache in php-src. The reason unfortunately is not explained. No existing tests require that userland error handlers do not trigger in `opcache_compile_file()`. The newly added tests are intended to exercise all possible kinds of edge-cases that might arise and cause issues (e.g. throwing Exceptions, performing a bailout, or loading a different file from within the error handler). They all pass for both `--repeat 1` and `--repeat 2`, as well as with OPcache enabled and without OPcache enabled (in the latter case with the exception of the `opcache_get_status()` verification). The list of cached files at the end of execution also matches my expectations. Therefore it seems that disabling the userland error handler when compiling a file with OPcache is not (or at least no longer) necessary. Fixes php#17422.
…ile()` The logic to disable userland error handlers existed since the first commit including OPcache in php-src. The reason unfortunately is not explained. No existing tests require that userland error handlers do not trigger in `opcache_compile_file()`. The newly added tests are intended to exercise all possible kinds of edge-cases that might arise and cause issues (e.g. throwing Exceptions, performing a bailout, or loading a different file from within the error handler). They all pass for both `--repeat 1` and `--repeat 2`, as well as with OPcache enabled and without OPcache enabled (in the latter case with the exception of the `opcache_get_status()` verification). The list of cached files at the end of execution also matches my expectations. Therefore it seems that disabling the userland error handler when compiling a file with OPcache is not (or at least no longer) necessary. Fixes php#17422.
The bug is still present on PHP 8.4.4 |
Confirming seeing this issue, that specific deprecation ignoring our error handlers messes up our json outputs and blocks us from upgrading to 8.4. Fixing all deprecations isn't an option, as we can do so in our own code but not in the packages that we use. |
The bug is still present on PHP 8.4.5. |
I can confirm this issue is present on our symfony app |
Confirmed this still happens on PHP 8.4.6 too. |
Description
The OPcache bypasses the user-defined error handler for deprecations for the first request with a cold cache. This happens regardless of
opcache.record-warnings
which only has an impact on all following requests. Enablingopcache.record-warnings
will yield the expected behavior for every request after the first one which populated the cache.This does not happen when OPcache is disabled, it will behave properly for every request.
test.php
dependency.php
This can be reproduced on a web server whenever
opcache_reset()
reset is invoked but for simplicity this was also verified to be triggered via CLI (thanks to @TimWolla for this suggestion):(Note: There is a bonus bug hiding here, the deprecation message is printed twice. However, the first message starts with
PHP Deprecated: (…)
but the second message only readsDeprecated: (…)
.)The script was also invoked manually via CLI without OPcache to verify that the behavior is identical to FPM:
PHP Version
PHP 8.4.2
Operating System
macOS 15.1.1
The text was updated successfully, but these errors were encountered: