Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Kernel Error From cache:clear After Upgrade #53566

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

Closed
miqrogroove opened this issue Jan 17, 2024 · 11 comments
Closed

Kernel Error From cache:clear After Upgrade #53566

miqrogroove opened this issue Jan 17, 2024 · 11 comments

Comments

@miqrogroove
Copy link

Symfony version(s) affected

7.0.2

Description

Shortly after upgrading to v7.0 I tried to switch my dev site to the prod environment so that I can see things without the verbose messages and profiler. Everything is working fine in the dev environment. I got some 500 status pages in prod and then remembered I need to clear the cache first. But now I can't clear the cache either!

$ bin/console cache:clear --env=dev

 // Clearing the cache for the dev environment with debug true

 [OK] Cache for the "dev" environment (debug=true) was successfully cleared.

$ bin/console cache:clear --env=prod
PHP Fatal error:  Declaration of ContainerFLCn0pU\App_KernelProdContainer::getParameter(string $name) must be compatible with Symfony\Component\DependencyInjection\Container::getParameter(string $name): UnitEnum|array|string|int|float|bool|null in var/cache/prod/ContainerFLCn0pU/App_KernelProdContainer.php on line 1070

How to reproduce

All I did was try to use cache:clear.

Possible Solution

No response

Additional Context

This particular project is rarely in prod mode and has been through a few upgrades since installing v5.4 about 10 months ago.

$ php -v
PHP 8.3.1 (cli) (built: Dec 21 2023 20:11:48) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.1, Copyright (c), by Zend Technologies
@miqrogroove
Copy link
Author

Workaround, based on the path info in the error message:

$ mv var/cache/prod var/cache/prod-old
$ bin/console cache:clear --env=prod

 // Clearing the cache for the prod environment with debug false

 [OK] Cache for the "prod" environment (debug=false) was successfully cleared.

@xabbuh
Copy link
Member

xabbuh commented Jan 17, 2024

Does the issue persist or are you now able to run the cache:clear command without any errors after applying your workaround?

@miqrogroove
Copy link
Author

The workaround is to manually remove the entire cache. The issue does not persist after clearing the cache. However, because the cache:clear command is broken in this scenario, I can easily reproduce the issue by restoring the cache.

This could be either a console issue or an upgrade documentation issue or both. I doubt the problem is specific to the kernel.

@stof
Copy link
Member

stof commented Jan 17, 2024

Upgrading to 7.0 from which version ?

@miqrogroove
Copy link
Author

I'll check the composer.json log for details...

5.4 in January
6.3 in August
6.4.2 yesterday
7.0.2 yesterday

@stof
Copy link
Member

stof commented Jan 18, 2024

this is weird. In 6.4, the generated container should not have ContainerFLCn0pU\App_KernelProdContainer::getParameter(string $name). Was your prod cache really generated by Symfony 6.4 before the upgrade to 7.0 or have you tried upgrading your prod cache directly from 5.4 to 7.0 ?

The generated cache is not compatible with 2 major versions higher.

@miqrogroove
Copy link
Author

miqrogroove commented Jan 18, 2024

As I mentioned in the top post, this machine is rarely ever in prod mode. So yes the cache was either from 5.4 or 6.3. The docs don't say anything about "upgrading your prod cache".

https://symfony.com/doc/current/setup/upgrade_major.html

@xabbuh
Copy link
Member

xabbuh commented Jan 18, 2024

I am not convinced that having an application pending over several major versions, but never deploy them to production is a use case common enough to be explicitly mentioned in the upgrade guide.

In any case this then doesn't seem to be an actual issue with the code then, but please feel free to open an issue in the docs repository if you thin that the docs can somehow be improved around this topic.

@xabbuh xabbuh closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2024
@miqrogroove
Copy link
Author

I am not convinced that having an application pending over several major versions, but never deploy them to production is a use case common enough to be explicitly mentioned in the upgrade guide.

Slightly off topic but following the best practices from the same docs, the prod environment is on the live server and the dev is on a separate machine with different local configs for debugging, meaning they have separate caches. I don't see how that's not a common use case?

@xabbuh
Copy link
Member

xabbuh commented Jan 18, 2024

Maybe I misunderstand your previous comment then. Having the dev environment locally when debugging and prod on production is of course a common use case and how you should work with your applications. But that doesn't explain why your cache would need to "jump" from 5.4 to 7.0.

@miqrogroove
Copy link
Author

Cache needs to jump based on how often (if ever) the config is changed on the dev machine. Essentially because the dev machine almost never needs to use the prod cache, and because the upgrading instructions don't direct any manual changes to either the config nor the cache itself. And you're saying the console is incompatible with doing it that way, which is just new info from my perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants