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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

anybody created an issue. See original summary.

velmir_taky made their first commit to this issue’s fork.

velmir_taky’s picture

Status: Active » Needs work

The problem is in linkTemplates() — it loops through all form handlers, including content_translation_deletion added by content_translation module. This creates a fake link template that toUrl() can't handle.

Changes:

- linkTemplates() now only iterates over add, edit, delete form handlers
- toUrl() falls back to parent::toUrl() for unknown rels instead of throwing RuntimeException
- Fixed URL::fromRoute => Url::fromRoute (wrong case)

Pipeline has two failures that are not related to this fix:
phpstan — 19 errors in EntityExtraFieldMapper.php and EntityExtraFieldListBuilder.php that already existed before my changes. I added phpstan-baseline.neon to 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.

velmir_taky’s picture

Status: Needs work » Needs review
grevil’s picture

Assigned: droath » grevil

Code 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!

grevil’s picture

Assigned: grevil » Unassigned
Status: Needs review » Reviewed & tested by the community

Good 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.

grevil’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Nice work! Did you already tag a new release with this fix @grevil? Setting this fixed now!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

grevil’s picture

Yes.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.