Problem/Motivation
When trying to delete an entity extra field, I get the following error:
RuntimeException: Unable to find content_translation_deletion-form to build a URL. in Drupal\entity_extra_field\Entity\EntityExtraField->toUrl() (line 493 of modules/contrib/entity_extra_field/src/Entity/EntityExtraField.php).
Backtrace:
Drupal\Core\Entity\EntityBase->{closure:Drupal\Core\Entity\EntityBase::uriRelationships():316}()
array_filter() (Line: 316)
Drupal\Core\Entity\EntityBase->uriRelationships() (Line: 106)
Drupal\menu_link_content\Hook\MenuLinkContentHooks->entityPredelete()
call_user_func_array() (Line: 216)
Drupal\migrate_boost\Decorators\MigrateBoostModuleHandler->{closure:Drupal\migrate_boost\Decorators\MigrateBoostModuleHandler::invokeAll():209}() (Line: 191)
Drupal\migrate_boost\Decorators\MigrateBoostModuleHandler->{closure:Drupal\migrate_boost\Decorators\MigrateBoostModuleHandler::invokeAllWith():191}() (Line: 340)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 191)
Drupal\migrate_boost\Decorators\MigrateBoostModuleHandler->invokeAllWith() (Line: 209)
Drupal\migrate_boost\Decorators\MigrateBoostModuleHandler->invokeAll() (Line: 336)
Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook() (Line: 491)
Drupal\Core\Entity\EntityStorageBase->delete() (Line: 378)
Drupal\Core\Entity\EntityBase->delete() (Line: 66)
Drupal\entity_extra_field\Form\EntityExtraFieldFormDelete->submitForm() (Line: 108)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 45)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 615)
Drupal\Core\Form\FormBuilder->processForm() (Line: 347)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}() (Line: 634)
Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():634}()
Fiber->start() (Line: 635)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 118)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 92)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 263)
Drupal\shield\ShieldMiddleware->bypass() (Line: 219)
Drupal\shield\ShieldMiddleware->handle() (Line: 62)
Drupal\crowdsec\Middleware->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 49)
Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 745)
Drupal\Core\DrupalKernel->handle() (Line: 19)
As the backtrace shows module "menu_link_content" very early, it could be a conflict or incompatibility with it.
Steps to reproduce
Try to delete a freshly created Entity Reference Field (Display > View)
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #4
velmir_taky commentedThe problem is in
linkTemplates()— it loops through all form handlers, includingcontent_translation_deletionadded bycontent_translationmodule. This creates a fake link template thattoUrl()can't handle.Changes:
-
linkTemplates()now only iterates overadd,edit,deleteform handlers-
toUrl()falls back toparent::toUrl()for unknown rels instead of throwingRuntimeException- Fixed
URL::fromRoute=>Url::fromRoute(wrong case)Pipeline has two failures that are not related to this fix:
phpstan— 19 errors inEntityExtraFieldMapper.phpandEntityExtraFieldListBuilder.phpthat already existed before my changes. I addedphpstan-baseline.neonto ignore them, but it looks like the CI removes this file before running the analysis, so I'm not sure how to fix that from my side.composer — fails during dependency installation on PHP 8.5 +
drupal/core: main-dev. This also seems to be a pre-existing CI issue.The actual fix works as expected. Let me know if you have any feedback on the code itself.
Comment #5
velmir_taky commentedComment #6
grevil commentedCode and changes make sense and look good to me!
I'll test this locally and remove the "phpstan.neon", not really sure why we have that. We should simply use the core's phpstan.neon, which is used by the CI automatically. Thanks though for trying to fix it!
Comment #7
grevil commentedGood stuff! Works as expected!
I reverted the phpstan changes, but decided to not delete the phpstan.neon here, hence that would be beyond the scope of this issue.
Comment #8
grevil commentedComment #11
anybodyNice work! Did you already tag a new release with this fix @grevil? Setting this fixed now!
Comment #13
grevil commentedYes.