user field not removed cleanly, breaks all node edit due to author link

Created on 16 August 2022, over 2 years ago
Updated 24 February 2023, almost 2 years ago

Problem/Motivation

when removing a custom field in
https://www.lmgm9.ugent.be/admin/config/people/accounts/fields

user field not removed cleanly, breaks all node edit due to author link or user entity reference.

error The website encountered an unexpected error. Please try again later.
Drupal\Core\Entity\Query\QueryException: 'field_user_id_account' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 369 of core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).

field still listed in contend devel display full dump attached

  [settings:protected] => Array
                        (
                            [handler] => default:user
                            [handler_settings] => Array
                                (
                                    [target_bundles] =>
                                    [sort] => Array
                                        (
                                            [field] => field_user_id_account
                                            [direction] => DESC
                                        )

                                    [auto_create] =>
                                    [filter] => Array
                                        (
                                            [type] => role
                                            [role] => Array(9)
                                        )

                                    [include_anonymous] =>
                                )

                        )

                    [required:protected] => 1
                    [translatable:protected] =>
                    [default_value:protected] => Array

readding the field removes the error(db field get created again)

Steps to reproduce

create account field
add entity reference field to user on Content type (mandatory?)
Add some content
remove custom account field
enjoy the error

Proposed resolution

complete delete all field references used or not

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
FieldΒ  β†’

Last updated 1 day ago

Created by

πŸ‡§πŸ‡ͺBelgium ikeigenwijs

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡©Bangladesh eashika

    Followed the steps, but could not reproduce them on fresh install of Drupal 9.5 and Drupal 10.1

  • Status changed to Postponed: needs info almost 2 years ago
  • Status changed to Closed: outdated 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Since there hasn't been a follow up in almost a year going to close out for now. If still valid please reopen adding steps to reproduce.

  • Status changed to Active 10 days ago
  • πŸ‡§πŸ‡ͺBelgium ikeigenwijs

    i was going through old tickets,
    still an issue when removing te old field from user profile.

    i dont know how to reproduce exactly.
    but we did this:
    1) create field 'user_id_account' in /admin/config/people/accounts/fields
    wil result in 'field_user_id_account'
    2) I presume this field is added to projects on some point, not visible now(prior to removing the recreated field)
    also no usages listed on /admin/config/people/accounts/fields

    3) remove the field in /admin/config/people/accounts/fields
    when deleting this field some reference stays of this field somewher, did not find it.
    4) edit node, save /node/101/editget error

    field does not appear on the contenttype but node save breaks everyphin.
    did cache clear after removal.

    a pointer to the richt location or tables, next search is just a file And db grep to vind the ghost entry.

    found references in following tables:
    key_value_expire
    config
    cache_default
    cache_config
    key_value
    cache_delta

    Quite a lot for a deleted field and cleared cache

    The website encountered an unexpected error. Try again later.
    
    Drupal\Core\Entity\Query\QueryException: 'field_user_id_account' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 369 of core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).
    Drupal\Core\Entity\Query\Sql\Tables->addField() (Line: 296)
    Drupal\Core\Entity\Query\Sql\Query->getSqlField() (Line: 197)
    Drupal\Core\Entity\Query\Sql\Query->addSort() (Line: 83)
    Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 391)
    Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->validateReferenceableEntities() (Line: 133)
    Drupal\Core\Entity\Plugin\Validation\Constraint\ValidReferenceConstraintValidator->validate() (Line: 202)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateConstraints() (Line: 154)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode() (Line: 164)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validateNode() (Line: 106)
    Drupal\Core\TypedData\Validation\RecursiveContextualValidator->validate() (Line: 93)
    Drupal\Core\TypedData\Validation\RecursiveValidator->validate() (Line: 132)
    Drupal\Core\TypedData\TypedData->validate() (Line: 518)
    Drupal\Core\Entity\ContentEntityBase->validate() (Line: 188)
    Drupal\Core\Entity\ContentEntityForm->validateForm()
    call_user_func_array() (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers() (Line: 274)
    Drupal\Core\Form\FormValidator->doValidateForm() (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm() (Line: 593)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    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: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
Production build 0.71.5 2024