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

CommentFileSizeAuthor
devel_dump.txt117.34 KBikeigenwijs

Comments

ikeigenwijs created an issue. See original summary.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

enaznin’s picture

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

cilefen’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

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.

ikeigenwijs’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Closed (outdated) » Active

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)
quietone’s picture

Version: 10.3.x-dev » 11.x-dev

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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.