symfony: [Cache] Argument Count Error with PHP 7.4.12 and APC provider with preloading enabled
Symfony version(s) affected: 5.1.8
Description
Using the cache component with the APC provider in PHP 7.4.11 fails with the error message:
ArgumentCountError: Too few arguments to function Symfony\Component\Cache\Adapter\AbstractAdapter::throwError(), 2 passed in and exactly 4 expected
How to reproduce
Create a symfony app with opcache preloading enabled and attempt to access items in the cache with APC as the provider
I created a docker based reproduction of this at https://github.com/jrjohnson/reproduction-symfony-error-apc-opcache the error can be reproduced there by doing:
composer install
docker-compose build
docker-compose up
Then visit http://127.0.0.1:8000/ which will fail with a 500 error and messages logged to the console running docker-compose.
Additional context
I’m not sure this is a symfony issue at it’s core, but I was unable to reproduce it otherwise. The issue seems to originate in https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php#L158 but it isn’t necessary to actually cause an error to trigger the bug possibly due to something the preloader is doing.
Possible Solution
Changing the method signature to
public static function throwError($type, $message, $file = '', $line = 0)
Appears to fix the problem, but the documentation for set_error_handler don’t indicate to me that should be necessary so I hesitate to make that change without understanding why this is happening.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (20 by maintainers)
@nicolas-grekas Yes, I’ve seen a few reports of preloading issues with PHP 7.4.12. My suspicion is that this issues has been introduced by https://github.com/php/php-src/commit/3928b6b435f6c7c818e8211b2ecdeeb7191310d1 (the only preloading related commit in that release) and that the issue will be fixed by https://github.com/php/php-src/commit/6808968c896a18d2b9f309b2fe63d529058b78b4.
I can now confirm that this is resolved with PHP 7.4.13 (As well as the latest 8.0RC).
Clearly that’s not an issue with our error handler callbacks: they worked for years. We would to a disservice to the PHP community if we silently worked around the issue and didn’t report this to php. This is the third report about argument count errors in a few days (#39005 and #38976). Maybe this is a random coincidence, maybe not, but this is very suspicious. We should consider that these might have the same underlying cause.
Please open a PHP bug report.
/cc @nikic in case this rings a bell to you.
@derrabus, sure, I’ll do that right now against 4.4.
Fixing every error handler is a really heavy change. Let’s not do that unless we’re certain that we have to do it.
My suggestion: Only fix the one error handler that’s causing trouble for you and leave the rest as they are.
It actually does!