-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
opcache_compile_file() fails with Cannot redeclare function error when compiling multiple files with the same function #16668
Comments
I have put my test setup in https://github.com/joec4i/opcache-compile-tests . Thanks! |
Previously, this only worked for classes. It worked by preventing early binding, and then declaring the class at runtime. Instead of doing that, we now avoid calling zend_accel_load_script() completely, which prevents the functions from being added to the function table. Fixes phpGH-16668
Previously, this only worked for classes. It worked by preventing early binding, and then declaring the class at runtime. Instead of doing that, we now avoid calling zend_accel_load_script() completely, which prevents the functions from being added to the function table. Fixes phpGH-16668
Previously, this only worked for classes. It worked by preventing early binding, and then declaring the class at runtime. Instead of doing that, we now avoid calling zend_accel_load_script() completely, which prevents the functions from being added to the function table. Fixes phpGH-16668
Hi @joec4i, thanks for your report, and sorry for the delay. I agree that at least the documentation is misleading. https://www.php.net/manual/en/function.opcache-compile-file.php
The fix1 is breaking though, so we may not fix it in any supported versions. It should also be discussed on the mailing list. Footnotes |
I believe I was slightly confused by a different issue I previously dealt with i.e. amphp/amp#321 |
Description
The following code:
compile-test.php
releases/v1/functions.php
releases/v2/functions.php
Resulted in this output:
But I expected this output instead:
Additional Context:
The issue happens on both cli and php-fpm. It seems to be similar to https://bugs.php.net/bug.php?id=66066 . While the use case in bug 66066 might be less common in the real world and probably should be avoided, it's a perfectly valid use case to run multiple releases with similar files under the same php-fpm instance.
Workaround
Our current workaround is to compile different releases with different requests, i.e. PHP will happily process the following logics in two different requests.
compile-v1.php
compile-v2.php
opcache_get_status()['scripts']
shows that the two files have been compiled successfully.PHP Version
PHP 8.3.13
Operating System
No response
The text was updated successfully, but these errors were encountered: