Closed kozebobinka closed 3 years ago
I can't reproduce. Using the latest dev-master
version and running those commands in a real Symfony app using EasyAdmin, I can't see the error. I also tried not warming up the cache explicitly via a command, and it also worked.
Can you please debug if the cache warmer from EasyAdmin (this class: https://github.com/EasyCorp/EasyAdminBundle/blob/master/src/Cache/CacheWarmer.php) is called and if it generates the cached file? Thanks!
Note: I always delete the cache via rm -fr var/cache/*
and I haven't seen this error 🤔
I also get the very same problem when adding EasyAdmin with composer require easycorp/easyadmin-bundle
. Setting the version constraints to 3.0.*
solved the problem (while with 3.1.0
I got the error again), so it must be some change between 3.0.2 and 3.1.0.
CacheWarmer is called:
[16-Jul-2020 15:30:32 UTC] PHP Fatal error: EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry::__construct(): Failed opening required '/var/www/back-end/var/cache/dev/easyadmin/routes-dashboard.php' (include_path='.:/usr/local/lib/php') in /var/www/back-end/vendor/easycorp/easyadmin-bundle/src/Registry/DashboardControllerRegistry.php on line 26
[16-Jul-2020 15:30:32 UTC] PHP Stack trace:
[16-Jul-2020 15:30:32 UTC] PHP 1. {main}() /var/www/back-end/bin/console:0
[16-Jul-2020 15:30:32 UTC] PHP 2. Symfony\Bundle\FrameworkBundle\Console\Application->run() /var/www/back-end/bin/console:42
[16-Jul-2020 15:30:32 UTC] PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/back-end/vendor/symfony/console/Application.php:147
[16-Jul-2020 15:30:32 UTC] PHP 4. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/back-end/vendor/symfony/framework-bundle/Console/Application.php:83
[16-Jul-2020 15:30:32 UTC] PHP 5. Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() /var/www/back-end/vendor/symfony/console/Application.php:271
[16-Jul-2020 15:30:32 UTC] PHP 6. Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() /var/www/back-end/vendor/symfony/framework-bundle/Console/Application.php:97
[16-Jul-2020 15:30:32 UTC] PHP 7. Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand->run() /var/www/back-end/vendor/symfony/console/Application.php:1018
[16-Jul-2020 15:30:32 UTC] PHP 8. Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand->execute() /var/www/back-end/vendor/symfony/console/Command/Command.php:255
[16-Jul-2020 15:30:32 UTC] PHP 9. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() /var/www/back-end/vendor/symfony/framework-bundle/Command/CacheWarmupCommand.php:80
[16-Jul-2020 15:30:32 UTC] PHP 10. ContainerObGOjCY\srcApp_KernelDevDebugContainer->{closure:/var/www/back-end/var/cache/dev/ContainerObGOjCY/getCacheWarmerService.php:11-21}() /var/www/back-end/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:89
[16-Jul-2020 15:30:32 UTC] PHP 11. ContainerObGOjCY\srcApp_KernelDevDebugContainer->load() /var/www/back-end/var/cache/dev/ContainerObGOjCY/getCacheWarmerService.php:12
[16-Jul-2020 15:30:32 UTC] PHP 12. require() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:693
[16-Jul-2020 15:30:32 UTC] PHP 13. ContainerObGOjCY\srcApp_KernelDevDebugContainer->getValidator_BuilderService() /var/www/back-end/var/cache/dev/ContainerObGOjCY/getValidator_Mapping_CacheWarmerService.php:12
[16-Jul-2020 15:30:32 UTC] PHP 14. ContainerObGOjCY\srcApp_KernelDevDebugContainer->getDoctrine_Orm_DefaultEntityManagerService() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:3007
[16-Jul-2020 15:30:32 UTC] PHP 15. ContainerObGOjCY\srcApp_KernelDevDebugContainer->getDoctrine_Dbal_DefaultConnectionService() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:865
[16-Jul-2020 15:30:32 UTC] PHP 16. ContainerObGOjCY\srcApp_KernelDevDebugContainer->getNotifyServiceService() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:820
[16-Jul-2020 15:30:32 UTC] PHP 17. ContainerObGOjCY\srcApp_KernelDevDebugContainer->getTemplateFillerService() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:1898
[16-Jul-2020 15:30:32 UTC] PHP 18. ContainerObGOjCY\srcApp_KernelDevDebugContainer->getTwigService() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:1925
[16-Jul-2020 15:30:32 UTC] PHP 19. ContainerObGOjCY\srcApp_KernelDevDebugContainer->getCrudUrlGeneratorService() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:1640
[16-Jul-2020 15:30:32 UTC] PHP 20. EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry->__construct() /var/www/back-end/var/cache/dev/ContainerObGOjCY/srcApp_KernelDevDebugContainer.php:2019
Maybe it depends on the Symfony version, I have 4.4
And yes, downgrading to version 3.0.2 helped.
I am also getting this error for v3.1.0. It appears that line 27 of DashboardControllerRegistry.php is causing the issue:
$dashboardControllerRoutes = require $cacheDir . '/' . CacheWarmer::DASHBOARD_ROUTES_CACHE;
When the cache is cleared all files are removed so this line fails. Seems like DashboardControllerRegistry
is being called at some point during boot up causing the error? Running the cache:warmup
command resolves this issue temporarily (contrary to what kozebobinka is experiencing) allowing me to use v3.1.0. A quick fix would be to add a file exists check before require
but I am not sure if that is the right solution.
The same error. There is no error If add to service.yaml:
EasyCorp\Bundle\EasyAdminBundle\Cache\CacheWarmer:
tags:
- { name: kernel.cache_warmer }
I get same error for our project with symfony 4.4. Interestingly it does not produce any errors in clean symfony 4.4 project so it must be problem of other vendors or configuration. Any ideas how to debug this? UPDATE I have tried:
@maxkain it's really strange that the error solves adding that config ... because we already have that config in the services.php
file of the bundle (otherwise it wouldn't work at all):
->set(CacheWarmer::class)
->arg(0, new Reference('router'))
->tag('kernel.cache_warmer')
I run rm -fr var/cache/*
frequently in many projects that are using EasyAdmin too ... and I can't reproduce the error. Please, anybody experiencing this issue, share the exact steps to reproduce it. For example, let's start with this:
$ symfony new my_project --full
$ cd my_project/
$ composer require admin
Now, please tell me the steps needed to face the reported issue. Thanks!
@javiereguiluz I have updated the bin/console file from a new installed project, cleared the cache and the problem has gone.
@javiereguiluz I tried to get this error on new project. I installed all vendors from project where it doesn't work, but on new project it works. Have no idea how to reproduse... Hints from @maxkain doesn't work.
@kozebobinka try to install new framework-bundle recipe https://symfonycasts.com/screencast/symfony5-upgrade/framework-bundle-recipe
The error occurs again. It's something strange. So, adding a definition to services.yaml helps only.
And for me too. I have this problem in sf 5.1 and EasyAdmin 3.1. And
EasyCorp\Bundle\EasyAdminBundle\Cache\CacheWarmer:
tags:
- { name: kernel.cache_warmer }
Same here with symfony/framework-bundle:v5.1.5
and easycorp/easyadmin-bundle:v3.1.4
Clarification : all was working fine with easyadmin, i was able to go on my board, on entities list, create, edit actions...
But then the bug happened after submitting a "delete" action on an object in the admin interface. Then I was never able to solved the problem with rm -rf var/cache/dev
or php bin/console cache:clear
.
Same working solution like previous answers :
EasyCorp\Bundle\EasyAdminBundle\Cache\CacheWarmer:
tags:
- { name: kernel.cache_warmer }
After updating recipies and editing services.yaml it works, thanks.
Sadly I must close this because we don't have a way to reproduce this bug. Hopefully if someone faces this issue, they'll find this via Google and maybe they can provide more info so we can definitely fix the issue. Thanks!
I can confirm the bug with S5 + EA3, however I don't have more informations to provide for now. I temporarily fixed it the way @maxkain did.
Hello. Hours debugging helps figure out what's going on.
How to reproduce:
Step 1. Install profiler. composer require --dev symfony/profiler-pack
If profiler is installed framework-bundle uses vendor/symfony/framework-bundle/Resources/config/cache_debug.xml
instead vendor/symfony/framework-bundle/Resources/config/cache.xml
. cache_debug.xml
enabled cache_pool_clearer.cache_warmer
(Symfony\Bundle\FrameworkBundle\CacheWarmer\CachePoolClearerCacheWarmer
) service with tag kernel.cache_warmer
and priority 64
.
Step 2. Create doctrine event subscriber. Create class that have \Twig\Environment
dependence in constructor and tag doctrine.event_subscriber
Step 3. rm -rf var/cache && php bin/console c:wa
First cache warmer cache_pool_clearer.cache_warmer
requires validator.mapping.cache_warmer
that requires doctrine.orm.default_entity_manager
that requires doctrine.dbal.default_connection
that requires our new doctrine event subscriber that requires twig that requires (as extension) \EasyCorp\Bundle\EasyAdminBundle\Router\CrudUrlGenerator
that requires \EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry
that generates error because \EasyCorp\Bundle\EasyAdminBundle\Cache\CacheWarmer
did not prepared cache yet
It is enough to change the priority, but this solution is not reliable. I haven't learned yet how \Symfony\Bridge\Twig\Extension\LogoutUrlExtension
works similarly
Maybe routes should be downloaded lazily? I do not know
@nemishkor thanks for debugging this tricky issue. Let's reopen to see if we can fix this.
It looks like it is related to https://github.com/symfony/symfony/pull/39360
We haven't received any new comments about this issue in a long time, so it's probably fixed somehow (I still haven't seen this problem myself in the past months, so hopefully it didn't affect to many people). Thanks!
Describe the bug I removed the cache/dev folder and now I get the error:
[16-Jul-2020 15:03:43 UTC] PHP Warning: Uncaught ErrorException: Warning: require(/var/www/back-end/var/cache/dev/easyadmin/routes-dashboard.php): failed to open stream: No such file or directory in /var/www/back-end/vendor/easycorp/easyadmin-bundle/src/Registry/DashboardControllerRegistry.php:26
All tries to warmup cache give the same error
To Reproduce
rm -rf var/cache/*
php bin/console cache:warmup