Description
Describe the bug
When you go to an old url, while using pretty url's, you'll get an error on the crud controller index page:
EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext::getEntity(): Return value must be of type EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto, null returned
To Reproduce
Just go to any old crud url while using the old url structure and have pretty url's enabled:
https://localhost/admin?crudAction=index&crudControllerFqcn=App%5CController%5CAdmin%5CUserCrudController
Additional context
This error actually makes sense because the route isn't handled in the regular way anymore.
If you look in \EasyCorp\Bundle\EasyAdminBundle\EventListener\AdminRouterSubscriber::onKernelRequest()
, there is a way to redirect to the proper url.
// if this is a ugly URL from legacy EasyAdmin versions and the application
// uses pretty URLs, redirect to the equivalent pretty URL
This code will never run though, because before it gets there, we return:
if ($this->requestAlreadyProcessedAsPrettyUrl) {
return;
}
If i move this check just below the code, which handles the ugly urls, the system works like it should.
Could it be, that we either not set the $this->requestAlreadyProcessedAsPrettyUrl
correctly (because its not really handle, although it's marked like handled) or that we return to soon to detect old urls?