Can't delete entity (custom content type)

Created on 10 January 2025, 12 days ago

Problem/Motivation

Can't delete node which belongs to custom entity.

Steps to reproduce

Remove comment field (yes, I've removed...)
Create custom entity type
Add custome entity node
Try to remove node

I get this error

#0 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php(332): Drupal\Core\Entity\Sql\DefaultTableMapping->requiresDedicatedTableStorage()
#1 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php(468): Drupal\Core\Entity\Sql\DefaultTableMapping->getAllColumns()
#2 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php(212): Drupal\Core\Entity\Query\Sql\Tables->getTableMapping()
#3 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(58): Drupal\Core\Entity\Query\Sql\Tables->addField()
#4 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(177): Drupal\Core\Entity\Query\Sql\Condition->compile()
#5 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(82): Drupal\Core\Entity\Query\Sql\Query->compile()
#6 /home/www/drupal10/web/core/modules/comment/comment.module(328): Drupal\Core\Entity\Query\Sql\Query->execute()
#7 [internal function]: comment_entity_predelete()
#8 /home/www/drupal10/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): call_user_func_array()
#9 /home/www/drupal10/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
#10 /home/www/drupal10/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(415): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#11 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(217): Drupal\Core\Extension\ModuleHandler->invokeAll()
#12 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(900): Drupal\Core\Entity\EntityStorageBase->invokeHook()
#13 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(452): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()
#14 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(753): Drupal\Core\Entity\EntityStorageBase->delete()
#15 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/EntityBase.php(362): Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete()
#16 /home/www/drupal10/web/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php(71): Drupal\Core\Entity\EntityBase->delete()
#17 [internal function]: Drupal\Core\Entity\ContentEntityDeleteForm->submitForm()
#18 /home/www/drupal10/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array()
#19 /home/www/drupal10/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#20 /home/www/drupal10/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#21 /home/www/drupal10/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#22 /home/www/drupal10/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#23 /home/www/drupal10/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#24 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#25 /home/www/drupal10/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#26 /home/www/drupal10/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#27 /home/www/drupal10/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#28 /home/www/drupal10/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#29 /home/www/drupal10/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#30 /home/www/drupal10/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#31 /home/www/drupal10/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#32 /home/www/drupal10/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#33 /home/www/drupal10/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#34 /home/www/drupal10/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle()
#35 /home/www/drupal10/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#36 /home/www/drupal10/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#37 /home/www/drupal10/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#38 /home/www/drupal10/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#39 /home/www/drupal10/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#40 /home/www/drupal10/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#41 /home/www/drupal10/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#42 {main}
🐛 Bug report
Status

Active

Version

10.3

Component

default content system

Created by

🇮🇹Italy rmorelli

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @rmorelli
  • Hello. There is a stack trace but the actual error isn't there.

  • 🇮🇹Italy rmorelli

    Actual error is internal server error, ie a white page..

    Here is the messagge in dblog

    TypeError: Drupal\Core\Entity\Sql\DefaultTableMapping::requiresDedicatedTableStorage(): Argument #1 ($storage_definition) must be of type Drupal\Core\Field\FieldStorageDefinitionInterface, null given, called in /home/www/drupal10.3.1/web/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php on line 335 in Drupal\Core\Entity\Sql\DefaultTableMapping->requiresDedicatedTableStorage() (linea 525 di /home/www/drupal10.3.1/web/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php).

  • Would you please take these steps to ensure this issue gets attention?

    • Update the issue summary above to include the exception message. That will more clearly explain the bug, as readers will not have to read comments to find essential information.
    • Update the issue summary above with more detailed steps to reproduce from a clean Drupal install. In particular, explain exactly how to implement the custom entity type that is involved. Be sure to verify the steps yourself on a clean Drupal install.
    • Remove the "Needs issue summary update" tag and change the issue status to "Active".
  • 🇳🇿New Zealand quietone

    Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies .

  • 🇨🇭Switzerland berdir Switzerland

    Errors like this typically happens when doing an entity query on a non-existing field.

    This is mixing terminology, is it now a content type or an entity type?

    comment_entity_predelete(), which triggers the error, just does an entity query on entity id and entity type, that should absolutely not fail. It might be possible that your entity storage for comments is somehow messed up.

  • 🇮🇹Italy rmorelli

    @berdir you're right I've ended up commenting predelete

    Entity storage for comments it's surely broken because I've deleted comment field...
    Hopefully this week I'll have time to reproduce it on a fresh drupal installation

Production build 0.71.5 2024