Documented solutions are in comments, #6, #8, #24, #25, #26 and #27

Comments

smartparty created an issue. See original summary.

smartparty’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

Solution found, courtesy of https://www.previousnext.com.au/blog/update-drupal-core-84-step-by-step-...

In the case of my issues, 'node' was replaced with 'commerce_product' and 'commerce_product_variation' respectively.

/**
 * Fix entity.definitions.bundle_field_map key store with old bundles.
 */
function my_module_update_8001() {
  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $node_map = $field_map_kv_store->get('node');
  // Remove the field_dates field from the bundle field map for the page bundle.
  unset($node_map['field_dates']['bundles']['page']);
  $field_map_kv_store->set('node', $node_map);
}
Newb_Druper’s picture

@smartparty

I am having the same errors since I updated to 8.4

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: comment_body, bundle: comment_node_gallery_item

From the code you provided(comment #2), which modules would I place this hook function in? I copy the code into one custom module and ran it through the update but I'm still getting the errors in my log.

Not sure if Im doing it right, as I don't have much Drupal experience. Thanks.

challeypeng’s picture

@smartparty
I have the same problem, and no matter how I use dr entup to update file_entity module, it's always unsuccessful.

How should I do it?
Could you tell me the detail process?

wolfhowling’s picture

I to am having issues with this and creating a custom module with the code from comment #2 does not work how do i make use of that code snippet in drupal?

Newb_Druper’s picture

It seems others are still having this issue.

I did a bit more digging and found a similar problem but in drupal 7 https://www.drupal.org/project/drupal/issues/1351506
Looking at post 5(by WormFood), the solution is to look into table “field_config_instance” and finding your bundle name that is giving errors and deleting that row.

Note - If you got to “reports->field list” you will the same errors “ Undefined Index” (mark them down)- basically the Bundle name which are the same results if you were to check the “Reports->Recent Log messages”.

In Drupal 8 the table “field_config_instance” is not there. Looking at comment 2 of this thread I looked at the code and notice the service key_value.

Key_value is a table in drupal 8 that you need to investigate. Do a mysql command and search the column “value” for your bundle name in question. For example I wanted to search the bundle “comment_node_gallery_item “ so I did statement of:
Eg. SELECT * FROM `key_value` WHERE `value` LIKE '%comment_node_gallery_item%'

Then look at field result of Value which is a longblob type string. Look at its string content and you should see the bundle names and the field that you are searching for. If you are using PHPMyAdmin you may have to right click that value and save as a bin file. You can open with texteditor.

I then deleted this row but make sure to backup this table just to be sure.

Then flush your cache. You should not get the errors in your recent logs anymore of “non-existent config entity name returned by FieldStorageConfigInterface::getBundles()…..”

I am not experienced in Drupal so I have no idea if this would have implication on the rest of the website by deleting right from the database. So someone else can try and chime in would be great.

uno’s picture

I had the same issue, leftovers from removed content type from d6 module (previous to D7 upgrade), named Flashnode. Errors were shown after upgrade to D8.

I just created new content type with the same problematic machine name (in my case flashnode), and deleted it - the warnings are gone.

wolfhowling’s picture

In my case the problematic bundle is entity.definitions.bundle_field_map if i modify it i get serialization errors if i delete it the errors go away but the bundle never gets rebuild and that gives me pause since i don't know how that may make things go wrong in the future, is any way to rebuild this bundles after removing them? Cron, flush or database update does not do it.

Thanks.

Update 1: This could be a better solution than deleting tables.

  1. Using the code from @Newb_Druper above find what entity you need.

    In my case it was comment_node_article and when searching for that you will see this in the result "entity.definitions.bundle_field_map | comment " the important word here is the comment after the pipe, keep this in mind.


  2. Go to this address and download the command extension for drush

  3. Place the extension on on the command folder in the drush directory
    In my case is global so it is "C:\Users\USER\AppData\Roaming\Composer\vendor\drush\drush\commands"

  4. Clear drush cache "drush cc drush"

  5. Run drush rfm comment --force
    the force is important other wise it will not do it since the file exist already

  6. Type -y to accept the rebuild
    Notice this cannot be undone so you may want to backup the database just in case

  7. Done

This worked for me i have not more errors and the entity exist in my database without any problems upon inspecting the blob file i see that it removed the keys that where causing the issue and re-serialized the file so it does not give any other errors. If any one has a better option or if you find any problems with this please let me know.

A thanks to @Newb_Druper for the first code and to @swichers in github for the extension for drush all i did was put together 1 and 2 together.

acbramley’s picture

This is caused by deleting a field via config import. I'm going to dig through the issue queue to see if there's an existing issue out there but it looks like it's due to FieldDefinitionListener::onFieldDefinitionDelete not firing when field config is deleted via config import.

keramsey’s picture

acbramley: I am getting errors related to custom fields that were added to basic page and article in Drupal 7 prior to upgrading to Drupal 8.5.5. The fields and related content seem to have migrated properly. However, I receive error messages whenever I flush caches. Any advice on how to correct the errors?

Here is one of the errors:
A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: media_title, bundle: default

uno’s picture

Have you tried adding that field, human name: Media Title, machine name: media_title?

You can check usage of the fields under /admin/reports/fields

ashwinsh’s picture

As per #10, I have faced same problem with field collection field after migrating my D7 site to D 8.5.6. Got website encountered error for all admin pages.

pminf’s picture

I get

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: field_foo, bundle: menu_link_content

but can not solve it with #2, because the bundle "menu_link_content" is not listed in \Drupal::service('keyvalue')->getAll().

I've noticed that there is a field.storage.menu_link_content.field_foo.yml (and no other config file related to this field). Deleting this file and trying to import leads to

 Collection  Config                                       Operation
             field.storage.menu_link_content.field_foo  delete
Import the listed configuration changes? (y/n): y
Synchronized configuration: delete field.storage.menu_link_content.field_foo.                                                                                                                              [ok]
Finalizing configuration synchronization.                                                                                                                                                                    [ok]
Drupal\Core\Config\ConfigException: Errors occurred during import in _drush_config_import() (line 703 of /var/www/drupal/vendor/drush/drush/commands/core/config.drush.inc).                                    [error]
The import failed due for the following reasons:                                                                                                                                                             [error]
Unexpected error during import with operation delete for field.storage.menu_link_content.field_foo: SQLSTATE[42S02]: Base table or view not found: 1146 Table
'drupal.menu_link_content__field_foo' doesn't exist: SELECT 1 AS expression
FROM
{menu_link_content__field_foo} t
WHERE field_foo_target_id IS NOT NULL
LIMIT 1 OFFSET 0; Array
(
)

Is there any other way to get rid of this field without operating directly on database level?

pminf’s picture

Version: 8.4.0 » 8.5.6
Status: Closed (works as designed) » Needs work

Reopen it because #2 does not solve it for all entity types (e.g. menu_link_content).

keramsey’s picture

Sorry for the delay in responding. I checked /admin/reports/fields and see the fields listed. The associated content types contain the fields and the field contents seem to have migrated successfully.

I thought these custom fields from the old D7 site would migrate as content fields, not config fields, as the error messages seem to imply.

All 4 fields I receive errors on are listed at /admin/reports/fields as being used in '...'. The fields should belong to Basic Page and Article content types.

Are the content types not appearing in the Used In column on the field report page the issue? If so, how do I correct it?

keramsey’s picture

I am not familiar with the Drupal 8 database schema, but I would think there would be a table, or tables, that would associate fields with their associated content types (bundles). Does anyone know which table(s) are used?

keramsey’s picture

The fields related to the 4 errors (type=view) in the recent log report when flushing all caches are field_license, field_tags, media_title, and media_description.

By querying the database table key_value using where collection='entity.definitions.bundle_field_map' and value like '%(field_name)%', I can see that the fields are related to the file type for all 4 fields and that 2 of the fields are also related to either taxonomy_term or node. Here is the break down:
field_license: file, taxonomy_term
field_tags: file, node
media_description: file
media_title: file

I found the following tables in the database related to the 4 fields:
field_license: file__field_license, taxonomy_term__field_license
field_tags: file__field_tags, node__field_tags
media_description: file__media_description
media_title: file__media_title

Of the 6 tables related to the 4 fields, the following tables are empty:
file__field_license, file__field_tags, file__media_description, file__media_title

The other 2 tables (node__field_tags, taxonomy_term__field_license) were not empty.

Not sure if this is relevant information, but the following tables are empty: file_managed, file_metadata, file_usage, media_field_data, media_field_revision, media_revision

Not sure if this is relevant information, the following tables are not empty: taxonomy_term_field_data, taxonomy_term_field_revision, taxonomy_term_hierarchy

I assume the file__* tables were not populated properly during the migration and that is what is contributing to the errors, but I am not sure how to address the issues.

Do I need to rerun the upgrade? Any ideas how to fix this?

keramsey’s picture

I noticed that I also receive 4 errors on the Field List report that I think are related to the 4 fields that did not migrate properly:

Notice: Undefined index: default in Drupal\field_ui\FieldStorageConfigListBuilder->buildRow() (line 116 of core/modules/field_ui/src/FieldStorageConfigListBuilder.php).

keramsey’s picture

From what I gather, the errors I am receiving are accurate and the issues are related to the site upgrade using the migrate_drupal_ui module. I will open a new issue and link to it from here once I figure out where the errors are happening (migrate_drupal or migrate_drupal_ui).

vmilic’s picture

I had the same issue, applying the solution from #8 solved it!

StepanISK’s picture

I get the following errors on the tab fields.
Is this mistake of the same choreographer or another?
I have drupal 8.6.2

Notice: Undefined index: image in Drupal\field_ui\FieldStorageConfigListBuilder->buildRow() (line 119 of core/modules/field_ui/src/FieldStorageConfigListBuilder.php).
Drupal\field_ui\FieldStorageConfigListBuilder->buildRow(Object) (Line: 235)
Drupal\Core\Entity\EntityListBuilder->render() (Line: 23)
Drupal\Core\Entity\Controller\EntityListController->listing('field_storage_config')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 665)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Notice: Undefined index: image in Drupal\field_ui\FieldStorageConfigListBuilder->buildRow() (line 119 of core/modules/field_ui/src/FieldStorageConfigListBuilder.php).
Drupal\field_ui\FieldStorageConfigListBuilder->buildRow(Object) (Line: 235)
Drupal\Core\Entity\EntityListBuilder->render() (Line: 23)
Drupal\Core\Entity\Controller\EntityListController->listing('field_storage_config')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 665)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
StepanISK’s picture

Version: 8.5.6 » 8.6.2
crash_springfield’s picture

I couldn't get the solution in #8 to work in 8.6 because it now uses Drush 9 but I think this works: drush 9 command to rebuild Drupal 8.4+ field mappings

Beau Townsend’s picture

Many thanks to all, especially @Newb_Druper (#6) and @wolfhowling (#8) for your helpful information. I wanted to also achieve two goals with this comment.

The first is to point out that I have encountered this error on an install of Drupal 8.7.6, that was not upgraded from a previous version. The error occurs on un-installation of a custom module in which Feeds and FeedTypes are being programmatically generated during installation. The issue for me was a feeds_item field attached to a custom entity that is also provided by the custom module.

Secondly, I had some trouble initially deciphering some of the necessary information to resolve this error. For those in a position similar to mine (including being a MySQL newb), I wanted to document the exact steps that I took while working in a MAMP environment with Drush 8.1.15 (on a Mac, obviously).

As of the commitment of this patch (https://www.drupal.org/project/drupal/issues/2985907) in 8.6.x, the FieldStorageConfigInterface error should tell you the entity type, so you won't need to investigate MySQL. If you are using a Drupal version prior to 8.6.x, use the following code to log into MySQL, then execute @Newb_Druper's SQL

# Assume $ to be a command prompt.

# Log in to MySQL (Use your DB creds)
$ mysql -u root -p

# Once logged in, execute @Newb_Druper's SQL, replacing the LIKE argument with your field name.
mysql> SELECT * FROM `key_value` WHERE `value` LIKE '%your_field_name%'

# Per @wolfhowling's comment (#8), look for text that reads "entity.definitions.bundle_field_map | my_entity" and take the value to the right of the pipe as the entity name.

# Exit MySQL
mysql> \q;

# If you know the name of the entity, start here.

# Navigate into your .drush folder. It is most likely found @ ~/.drush
$ cd ~/.drush

# Clone the rfm command extension
$ git clone https://gist.github.com/d0141a3ab14d93835d09943684480ee0.git

# Navigate back to your Drupal instance
$ cd /Applications/MAMP/htdocs/drupal-8.7.6

# Clear drush cache, then rebuild your field mapping.

$ drush cc drush
$ drush rfm my_entity --force

These steps corrected the issue for me.

panchuk’s picture

Example for comment entity. I have this error when migrate d7 to d8:

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_schools_and_colleges, field name: comment_body

And I use HOOK_update in YOURMODULENAME.module

function YOURMODULENAME_update_8001() {
  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $comment_map = $field_map_kv_store->get('comment');
  // Remove the field_dates field from the bundle field map for the page bundle.
  unset($comment_map['comment_body']['bundles']['comment_node_schools_and_colleges']);
  $field_map_kv_store->set('comment', $comment_map);
}
nicolasambroise’s picture

Thanks @Panchuk, I manage to fix this 3 errors
* entity type : commerce_product, bundle: product, field name : field_deadline
* entity type : commerce_product, bundle: product, field name : commerce_stock_override
* entity type : commerce_product, bundle: product, field name : commerce_stock

function YOURMODULENAME_update_8001() {
  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $node_map = $field_map_kv_store->get('commerce_product');
  
  // Remove the field_deadline field from the bundle field map for the page bundle.
  unset($node_map['field_deadline']['bundles']['product]);
  
   // Remove the commerce_stock_override field from the bundle field map for the page bundle.
  unset($node_map['commerce_stock_override']['bundles']['product']);
  
   // Remove the commerce_stock field from the bundle field map for the page bundle.
  unset($node_map['commerce_stock']['bundles']['product']);
  
  $field_map_kv_store->set('node', $node_map);
}

After that, I enable the module, I call the /update.php, I clean the cache and now the error is gone.

ndf’s picture

Same as #25 but with variables for $entity_type, $bundle and $field_name on top for readability.

function YOURMODULENAME_update_8001() {
  ## Fixes:
  ## A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: paragraph, bundle: text, field name: field_image
  $entity_type = 'paragraph';
  $bundle = 'text';
  $field_name = 'field_image';

  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $map = $field_map_kv_store->get($entity_type);
  // Remove the field_dates field from the bundle field map for the page bundle.
  unset($map[$field_name]['bundles'][$bundle]);
  $field_map_kv_store->set($entity_type, $map);
}
mediameriquat’s picture

I have a similar error message when I submit a "Book" product in Drupal Commerce:

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: block_content, bundle: contact, field name: field_formulaire

The problem is unrelated to the product type. It stems from a WSOD that appeared while trying to put a contact form into a block. It is definitely a core issue.

--
Where should I insert the code suggested in #27 ? I don't even know which module to update. I'm on shared host w/o drush. Any help would be greatly appreciated.

kundu’s picture

#27 did the trick for me.

I added it in my custom module custom.module as custom_update_8001(){}.

Thanks¡

apathak’s picture

Similar questions as #2 @smartparty above:

1. Where does this code go?
1a . Do I need to write a custom module for this?
1b. What is _update_8001? (especially 8001?)
1c. How will this hook get fired in a custom module - I am getting the error after rebuilding the cache.

2. I have already tried what #6 @newb_druper suggested - it did not work for me. I am still getting the error.

/**
 * Fix entity.definitions.bundle_field_map key store with old bundles.
 */
function my_module_update_8001() {
  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $node_map = $field_map_kv_store->get('node');
  // Remove the field_dates field from the bundle field map for the page bundle.
  unset($node_map['field_dates']['bundles']['page']);
  $field_map_kv_store->set('node', $node_map);
}

Thank you for your help.

ndf’s picture

#29, #30: you can add code from #27 to any module.
But I guess you did yet write a lot of modules yourself.

Therefor you can follow these guides to write your first module:
- https://www.drupal.org/docs/8/creating-custom-modules
- http://redcrackle.com/blog/say-hello-world-drupal-8-basic-steps-involved...

In all these examples the update function starts with words like my_module, YOURMODULENAME and HOOK.
You should replace that with the machine-name of your module.
Read more about hooks here: https://api.drupal.org/api/drupal/core!core.api.php/group/hooks/8.4.x

At last the 8001 part. This is an increment. In Drupal 8 it is always 8001+ and in Drupal 7 it is always 7001+.
So for your first HOOK_update() you use HOOK_update_8001().
And for your second HOOK_update() you use HOOK_update_8002(), etc, etc.
You can read more about it here: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...

apathak’s picture

Hello @ndf,

Thanks a lot for your help and the detailed answer!

I have written a custom module, for example, my_module and the function my_module_update_8001()

I have installed the module (my_module). Now, my question is: how do I make sure that the function my_module_update_8001() is fired?

Thanks!

ndf’s picture

@apathak,
I forgot to say that hook_update() won't run when you install a module. Only when you run the update-script.
This is intentional! The idea is that a module does everything it needs in its hook_install() function.

Example:
- Not installed module has 2x hook_update defined (i.e. hook_update_8001() and hook_update_8002() )
- The module will be installed
--- Now the drupal system does *not* run hook_update_8001() and hook_update_8002()
--- But the drupal system will register that the module is in version 8002 (hook_update with highest number)
- The get's an update that has hook_update_8003()
- You install this update and you run the update script
--- Now the drupal system *will* run hook_update_8003()

So in your case you should first install your new custom module.
Then after that increase the hook_update_N number.
Then run the update script.

apathak’s picture

Hi @ndf,

Thanks again for the detailed answer.

I still have a few questions.

At the moment I am in my local environment.

1. I have installed my_module with my_module_update_8001 ()

2. How do I run the update-script after I increment the N in the hook_update_N() function?

3. When I increment the N to 8003 and try to: Administration>>Extend>>Update, I do not find my_module. How do I run the update script?

Thanks!

ndf’s picture

Hi @apathak, what you wrote in #34 should work.

Our discussion is now out-of-context for this issue #2916266: How to fix "non-existent config entity name returned by FieldStorageConfigInterface::getBundles()"
I think it would be better to ask for support in Drupal Slack (https://www.drupal.org/slack) #support or ask some other drupal-developer to sit together on your issue (maybe on a local event).
Those are more helpful places for support than the core issue-queue.

apathak’s picture

Hello @ndf,

This is how I ended up running "my_module" - via drush:

At the docroot, I ran the following drush command:

$ drush updb -y modules/custom/my_module

"my_module" being the module that I had written.

I was up to 8005 for my N.

Thanks for your help.

harishpatel86’s picture

@apathak,

You can enable new contributed or custom module by using below command:

drush en my_module -y.

See the reference : https://drushcommands.com/drush-8x/pm/pm-enable/

apathak’s picture

Hello @ndf, and others,

Here is another question I have - after I run my hook_update_N() - the following code, I get the warning

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 266 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

This is my code:

/**
* Implements hook_update_N().
 */
function recurring_log_error_update_8002()
{
  ## Fixes:
  ##  A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: ecqm_tool, field name: field_ecqm_tool_project_url

  $entity_type = 'node';
  $bundle = 'ecqm_tool';
  $field_name = 'field_ecqm_tool_project_url';

  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $map = $field_map_kv_store->get($entity_type);

  unset($map[$field_name]['bundles'][$bundle]);
  $field_map_kv_store->set($entity_type, $map);
}

Help is appreciated.

apathak’s picture

Here is the full warning:

Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 250)
Drupal\Core\Entity\EntityStorageBase->load() (Line: 74)
Drupal\workbench_moderation\ModerationInformation->loadBundleEntity('node_type', ) (Line: 82)
Drupal\workbench_moderation\ModerationInformation->isModeratableBundle(Object, ) (Line: 304)
Drupal\workbench_moderation\EntityTypeInfo->entityBundleFieldInfoAlter(Array, Object, ) (Line: 87)
workbench_moderation_entity_bundle_field_info_alter(Array, Object, ) (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('entity_bundle_field_info', Array, Object, ) (Line: 424)
Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions('node', , Array) (Line: 338)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('node', ) (Line: 39)
Drupal\ctools_block\Plugin\Deriver\EntityFieldDeriver->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 284)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('system_menu_block:about') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('system_menu_block:about', Array) (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance('system_menu_block:about', Array) (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin('system_menu_block:about') (Line: 57)
Drupal\block\BlockPluginCollection->initializePlugin('system_menu_block:about') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('system_menu_block:about') (Line: 45)
Drupal\block\BlockPluginCollection->get('system_menu_block:about') (Line: 83)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration(Array) (Line: 99)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId('system_menu_block:about', Array) (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct(Object, 'system_menu_block:about', Array) (Line: 34)
Drupal\block\BlockPluginCollection->__construct(Object, 'system_menu_block:about', Array, 'about') (Line: 156)
Drupal\block\Entity\Block->getPluginCollection() (Line: 145)
Drupal\block\Entity\Block->getPlugin() (Line: 118)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 370)
Drupal\Core\Entity\EntityBase->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 259)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 99)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

idflorin’s picture

Implemented #27 but I still get
A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: gallery_assist, field name: field_fpimage
This is code from my module

function hello_world_update_8001() {
  ## Fixes: https://www.drupal.org/project/drupal/issues/2916266#comment-13292415
  ## A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: gallery_assist, field name: field_fpimage
  $entity_type = 'node';
  $bundle = 'gallery_assist';
  $field_name = 'field_fpimage';

  /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $map = $field_map_kv_store->get($entity_type);
  // Remove the field_fpimage field from the bundle gallery_assist for the page bundle.
  unset($map[$field_name]['bundles'][$bundle]);
  $field_map_kv_store->set($entity_type, $map);
  
  }

and
https://prnt.sc/s6dh9a
in blog its tag Type is "views"
"gallery_assist" existed in drupal 6 https://www.drupal.org/project/gallery_assist
now its gone.
I found in my db "www_spare_wheel_" SELECT * FROM `www_spare_wheel_`.`key_value` WHERE (CONVERT(`collection` USING utf8) LIKE '%gallery_assist%' OR CONVERT(`name` USING utf8) LIKE '%gallery_assist%' OR CONVERT(`value` USING utf8) LIKE '%gallery_assist%')
this BLOB.
It's safe to delete it?
https://prnt.sc/s6dmbp
thank you.

idflorin’s picture

Implemented #27 = fixed
made: function hello_world_update_8001 install, run, uninstall, made, function hello_world_update_8002, install, run , uninstall , made function hello_world_update_8003 .. etc for how many errors do you have.

Version: 8.6.2 » 8.6.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.6.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

bmango’s picture

I couldn't get my_module_update_8001() to run until I realised I needed to change it to my_module_update_8801() as I was running Drupal 8.8!

Maybe this will help someone else :)

sseto’s picture

I also couldn't get my my_module_update_8801() to run until I realized I needed to change my_module_update_8901()

Hopefully this helps someone :)

dillix’s picture

@apathak did you resolve this issue? I also have a lot of warnings after hook_update().

TomChiverton’s picture

Still happens on D7 to D9 conversion

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: poll, field name: upload

mogio_hh’s picture

#27 worked with me. As on 8.9.3 I had to rename the hook to

drush updb
xxx_update_8901
drush updb
xxx_update_8902
drush updb
xxx_update_8903

Thanks for that.

juliyo7’s picture

HI, i have this error using migrate module to migrate Drupal7 to Drupal8:

User warning: Missing file with ID 2232. en Drupal\image\Plugin\Field\FieldType\ImageItem->preSave() (línea 329 de /home/migracion/public_html/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php)

The content fields haven't migrated with that module, anyone cant help me?

sjhuskey’s picture

I'm on Drupal 8.9.6.

Here's one of many similar errors that I'm trying to fix:

A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_time_slot_institution, field name: comment_body

I created a module called scs_fix. In scs_fix.module, I inserted the code from #27, with the variables altered for my situation, and I named the function scs_fix_update_8901:

function scs_fix_update_8901() {
$entity_type = 'comment';
$bundle = 'comment_node_time_slot_institution';
$field_name = 'comment_body';
/** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $map = $field_map_kv_store->get($entity_type);
  // Remove the field_dates field from the bundle field map for the page bundle.
  unset($map[$field_name]['bundles'][$bundle]);
  $field_map_kv_store->set($entity_type, $map);
}

I enabled the module.

When I ran drush updatedb, I found that there were no updates to apply.

Is there some step that I'm missing?

dillix’s picture

@sjhuskey I tried this way, but after update I've got a bunch of errors like this:

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 266 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 250)
Drupal\Core\Entity\EntityStorageBase->load() (Line: 544)
Drupal\Core\Entity\EntityBase::load() (Line: 330)
Drupal\comment\Entity\Comment::bundleFieldDefinitions(Object, , Array) (Line: 371)
Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions('comment', , Array) (Line: 338)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('comment', ) (Line: 39)
Drupal\ctools_block\Plugin\Deriver\EntityFieldDeriver->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 284)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('local_tasks_block') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('local_tasks_block', Array) (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance('local_tasks_block', Array) (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin('local_tasks_block') (Line: 57)
Drupal\block\BlockPluginCollection->initializePlugin('local_tasks_block') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('local_tasks_block') (Line: 45)
Drupal\block\BlockPluginCollection->get('local_tasks_block') (Line: 83)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration(Array) (Line: 99)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId('local_tasks_block', Array) (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct(Object, 'local_tasks_block', Array) (Line: 34)
Drupal\block\BlockPluginCollection->__construct(Object, 'local_tasks_block', Array, 'seven_secondary_local_tasks') (Line: 156)
Drupal\block\Entity\Block->getPluginCollection() (Line: 145)
Drupal\block\Entity\Block->getPlugin() (Line: 118)
Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 370)
Drupal\Core\Entity\EntityBase->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 259)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
kanchamk’s picture

#26 Worked for me. Thanks!.

Just put that code in your custom module hook_update_N function(Here N could be anything like 8001 or 8901 irrespective of your d8 version).

Run below commmand

drush updb

to see the results.

Note: if there are so many errors coming from taxonomy_term, node and paragraph etc, Just increment the N number by 1 and change entity_type to taxonomy_term, node and paragraph respectively and run above drush command every time.

ivnish’s picture

#27 thanks!

chike’s picture

I upgraded from Drupal 7 to 8 and had this issue exactly the error I had was A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: comment, bundle: comment_node_fire_protection_system, field name: comment_body

I tried #27 but after enabling the module I expected the issue to go away but it didn't. Perhaps I was supposed to run database update but I didn't think of that so I removed the module and tried @Newb_Druper's solution at #6, so I opened phpMyAdmin and deleted the entry as explained in #6 and the issue went away.

In my case it wasn't only that I was getting notices each time I enable or disable modules with Drush but if I enabled layout_builder the site will throw WSOD and become inaccessible till I disable layout_builder again. So after deleting the item from db I am able to enable layout_builder and use the site without the notices.

I am just hoping there are no trailing issues lurking somewhere but for now site works.

jprj’s picture

Like chike, I am upgrading from Drupal 7 to 8 (btw I'm on drupal 8.9.x). I hit the same problem, tried #27 which worked on one error, but didn't work on the second. So I tried #6. The net result is that there are no longer any errors in dblog, but I still get the WSOD, which is more frustrating. I don't have layout_builder enabled, so that should not be part of the problem (I hope). I will keep plodding away at it.

baluertl’s picture

Thank you everyone in this thread for the valuable hints. With them in mind, I was able to successfully investigate that for me the issue happened because I renamed the coreʼs system.menu.main config file to something else. Once the original "system.menu.main.yml" file was restored, the /admin/reports/fields page was loading again properly.

brooke_heaton’s picture

I've run the suggested update and am now also getting the 'array_flip()' warning:


Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 266 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 250)
Drupal\Core\Entity\EntityStorageBase->load() (Line: 544)
Drupal\Core\Entity\EntityBase::load() (Line: 443)
Drupal\commerce_product\Entity\Product::bundleFieldDefinitions(Object, , Array) (Line: 371)
Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions('commerce_product', , Array) (Line: 338)

I do not suggest the solution in #27 due to the recurring errors.

mkrkarthi’s picture

I had the same error for comments, node and media. Created the respective content / comment /media types with the same bundle name and deleted it.
Errors disappeared.

djassie’s picture

Issue summary: View changes
StatusFileSize
new17.13 KB

Credit goes to #6 #24 and previous post of years back targeting

Drupal Version: 9.2.0 - release version
Only local images are allowed.

My issue: A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: node, bundle: article, field name: body
After deleting content_type: Article

I was getting the above error, that non-existent config entity name returned by FieldStorage ...

I trying - with - the above - creating and instaling the hook_update_N module, and after installing, going to url/update.php or drush updb -y

/*
  *file_name clearconfig03.install, along with blank .module file according to https://www.drupal.org/docs/7/creating-custom- 
  *modules/howtos/examples-for-database-update-scripts-using-hook_update_n-how  and info.yml file
  */
 function clearconfig03_update_9021(){
   /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
  $key_value_factory = \Drupal::service('keyvalue');
  $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
  $node_map = $field_map_kv_store->get('node');
  
  // Remove the field_deadline field from the bundle field map for the page bundle.
  unset($node_map['field_body']['bundles']['article']);
  $field_map_kv_store->set('node', $node_map);
 }

But the above did not work.

Working solution, which at least worked :
In Database(MySQL Workbench, find/run query
use d77;
SELECT * FROM `key_value` WHERE `value` LIKE '%article%';

Now, I got only one - row, can not rember the row.
In the row, openend the blob file, in MySQL Workbench default editor. I find the value present article.

After deleting, the row, and applied, and commited.

Cleaning Cache

TRUNCATE cache_config;
TRUNCATE cache_container;
TRUNCATE cache_data;
TRUNCATE cache_default;
TRUNCATE cache_discovery;
TRUNCATE cache_dynamic_page_cache;
TRUNCATE cache_entity;
TRUNCATE cache_menu;
TRUNCATE cache_render;

Now, finally, run drush cr to reload cache.

When I opened the website log, now I do not get the previous error of missing error of non-existent config entity name

sjhuskey’s picture

The solutions mentioned above (e.g., #25 and #27) work on single instances of the error, but if you have multiple errors, you can modify #27 with a foreach statement.

I had many errors, so I wanted to fix all of them at one time. Since the error is in the form of, for example, [error] A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: taxonomy_term, bundle: blog_category, field name: field_title, you have the beginnings of an array. I copied all of the errors, then I deleted everything but the entity type (e.g., taxonomy_term), bundle (e.g., blog_category), and field_name (e.g., field_title) and turned the result into an array of arrays. Then I used foreach to iterate over the arrays.

Here's an example:

<?php

function my_module_update_8904() {

  $problem_fields = array (
    array("comment","comment_node_time_slot_institution","comment_body"), 
    array("comment","comment_node_annual_meeting_abstract","comment_body"), 
    array("comment","comment_node_blog","comment_body"), 
    array("taxonomy_term","blog_category","field_title"), 
  );

  foreach($problem_fields as $arr){

    $entity_type = $arr[0];
    $bundle = $arr[1];
    $field_name = $arr[2];

    /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
    $key_value_factory = \Drupal::service('keyvalue');

    $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');

    $map = $field_map_kv_store->get($entity_type);

    // Remove the field_fpimage field from the bundle gallery_assist for the page bundle.
    unset($map[$field_name]['bundles'][$bundle]);

    $field_map_kv_store->set($entity_type, $map);
  }
}

I hope that this helps someone.

vrwired’s picture

Thanks @sjhuskey, good example in #60. Also, if anyone else has issue with 'no pending updates', make sure to name file with .install extension and if that's not the issue, then increment the hook (mymodule_update_8901 to mymodule_hook_8902). It'd been a while since I did a hook update and had to recall this over again.

edward.peters’s picture

#27 worked for me too, when upgrading a site from Drupal 7 straight to Drupal 9.2.7. Thank you!

andypost’s picture

Version: 8.9.x-dev » 9.3.x-dev
sseto’s picture

I'm getting this warning after using the custom module for my D9 site:

Warning: array_flip(): Can only flip STRING and INTEGER values! in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 261 of C:\wamp64\www\sseto\web\core\lib\Drupal\Core\Entity\EntityStorageBase.php)

Any idea what could be the issue?

EDIT: I re-imported my old DB and used #6 way instead and it's fixed.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

junaidpv’s picture

I made solution from #27 as a Drush command. Here is a gist containing two files https://gist.github.com/junaidpv/3a5211deec20ae770e6d93a6a9d2c8bd
Instructions:

  1. Replace "my_module" in both files with name of your module
  2. Put drush.services.yml in module direcotry along with the .info file of the module.
  3. Put UpdateCommands.php within "src/Commands" directory withing the module directory

We can the drush command as:

drush10 update:correct-field-config-storage entity_type bundle field_name

Please use correct values for entity_type, bundle and field_name with respective values from your error messages.

cobasa’s picture

I got my fix from comment #66! Thanks junaidpv

la558’s picture

I got my fix from comment #66! Thanks junaidpv

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ihor_allin’s picture

#60 helped me. Thank you sjhuskey

tmacy’s picture

Version: 9.5.x-dev » 8.5.x-dev
Issue tags: +code fix offered
StatusFileSize
new1.55 KB

I've run into the "non-existent config entity name returned by FieldStorageConfigInterface::getBundles" problem updating a legacy site from D7 to D8/9. As per the #2 code, I cobbled the following code for a D8 module. It worked. Note that it is a brute solution by choice.

<?php
/**
* @file
* Contains \Drupal\hello_world\Controller\HelloController.
*/
namespace Drupal\emf_tester\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
* * Fix entity.definitions.bundle_field_map key store with old bundles.
*/
class BundleFixController extends ControllerBase {
/**
* Based on solution code here:
* https://www.drupal.org/project/drupal/issues/2916266
*
* Chose to use brute force method, i.e., one error at a time, to verify
* and to serve as a log of changes. Last found at bottom.
*/
public function content() {

/** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
$key_value_factory = \Drupal::service('keyvalue');
$field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');

// Caution: Set $entity_type, $bundle manually as taken for errors such as these:
//
// - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// entity type: node, bundle: image, field name: upload
// $entity_type = 'node';
// $bundle_name = 'image'; //advpoll_ranking';
// $field_name = 'upload';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product, field name: upload
// $entity_type = 'node';
// $bundle_name = 'product';
// $field_name = 'upload';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product_gift_dues, field name: taxonomyextra
// $entity_type = 'node';
// $bundle_name = 'product_gift_dues';
// $field_name = 'taxonomyextra';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product_kit, field name: taxonomyextra
// $entity_type = 'node';
// $bundle_name = 'product_kit';
// $field_name = 'taxonomyextra';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product_kit, field name: field_image_cache
// $entity_type = 'node';
// $bundle_name = 'product_kit';
// $field_name = 'field_image_cache';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product_dues, field name: field_image_cache
// $entity_type = 'node';
// $bundle_name = 'product_dues';
// $field_name = 'field_image_cache';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_call_abstract_submission, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_call_abstract_submission';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_product, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_product';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_product_kit, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_product_kit';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_advpoll_binary, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_advpoll_binary';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_advpoll_ranking, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_advpoll_ranking';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_image, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_image';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_webform, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_webform';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product, field name: body
// $entity_type = 'node';
// $bundle_name = 'product';
// $field_name = 'body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product_kit, field name: body
// $entity_type = 'node';
// $bundle_name = 'product_kit';
// $field_name = 'body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: advpoll_binary, field name: body
// $entity_type = 'node';
// $bundle_name = 'advpoll_binary';
// $field_name = 'body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: image, field name: body
// $entity_type = 'node';
// $bundle_name = 'image';
// $field_name = 'body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: comment, bundle: comment_node_product_gift_dues, field name: comment_body
// $entity_type = 'comment';
// $bundle_name = 'comment_node_product_gift_dues';
// $field_name = 'comment_body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: advpoll_ranking, field name: body
// $entity_type = 'node';
// $bundle_name = 'advpoll_ranking';
// $field_name = 'body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product_gift_dues, field name: body
// $entity_type = 'node';
// $bundle_name = 'product_gift_dues';
// $field_name = 'body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product, field name: field_image_cache
// $entity_type = 'node';
// $bundle_name = 'product';
// $field_name = 'field_image_cache';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: webform, field name: body
// $entity_type = 'node';
// $bundle_name = 'webform';
// $field_name = 'body';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: product_gift_dues, field name: field_image_cache
// $entity_type = 'node';
// $bundle_name = 'product_gift_dues';
// $field_name = 'field_image_cache';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // n entity type: node, bundle: product, field name: taxonomyextra
// $entity_type = 'node';
// $bundle_name = 'product';
// $field_name = 'taxonomyextra';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: advpoll_binary, field name: upload
// $entity_type = 'node';
// $bundle_name = 'advpoll_binary';
// $field_name = 'upload';
// // - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// // entity type: node, bundle: image, field name: upload
// $entity_type = 'node';
// $bundle_name = 'image';
// $field_name = 'upload';
// - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles():
// entity type: node, bundle: product_conf_reg, field name: field_image_cache
$entity_type = 'node';
$bundle_name = 'product_conf_reg';
$field_name = 'field_image_cache';

//
$node_map = $field_map_kv_store->get($entity_type);

// Remove the field_dates field from the bundle field map for the page bundle.
//unset($node_map['field_dates']['bundles']['page']);
//$field_map_kv_store->set('node', $node_map);

$html = '

Bundle: '.$bundle_name.'
' ; $html .= "Field map: ".print_r($field_map_kv_store, true); $html .= 'Before: Node map: '.print_r($node_map[$field_name]['bundles'], true); $html .= '-- value found:'.$node_map[$field_name]['bundles'][$bundle_name] ."
"; unset($node_map[$field_name]['bundles'][$bundle_name]); $html .= 'After: Node map after: '. print_r($node_map[$field_name]['bundles'], true); $html .= "

";

// *** Comment out next line to prevent database update. ***
//$field_map_kv_store->set($entity_type, $node_map);

return array(
'#type' => 'markup',
'#markup' => t('

'.$html.'

'),
);
}
}

andypost’s picture

Version: 8.5.x-dev » 9.5.x-dev
Issue tags: -code fix offered

no reason to change version as 8.x no longer supported

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.

rex.barkdoll’s picture

I just wanted to add that #66 worked for me. Huge appreciation to @junaidpv.

I just wanted to add some additional instructions for anyone else who's facing this afterward and who doesn't do a lot of Drupal development/coding.

Creating a module to solve this issue: A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type:

  1. You're going to create a custom module on your computer. Start by making a folder, I called mine "update_config_entity" If you want to use a different name, feel free to, you'll just need to make some adjustments to my code based on @junaidpv's code
  2. Inside this folder, create a file called update_config_entity.info.yml
    The contents will be:
    name: Update Config Entity Module
    description: Fixes Error - A non-existent config entity name returned by FieldStorageConfigInterface::getBundles() entity type comment, bundle.
    package: Custom
    
    type: module
    core_version_requirement: ^9.4 || ^10
    
  3. Create another file called drush.services.yml and go to @junaidpv's repository, copy the contents from their example of the same name into this file.
    • On line 3, change \Drupal\my_module\Commands\UpdateCommands to \Drupal\update_config_entity\Commands\UpdateCommands (or the name of your module)
  4. Create a folder called src, inside that, create a folder called Commands
  5. Inside the Commands folder, create a file called UpdateCommands.php
  6. Put the contents from @junaidpv's UpdateCommands file into your file.
    • Update line 3 from namespace Drupal\my_module\Commands; to namespace Drupal\update_config_entity\Commands;
  7. Now put the module in the /web/modules/custom/ folder in your site, activate it, and run the drush command.
  8. In your command line, run: drush update:correct-field-config-storage entity_type bundle field_name, changing entity_type, bundle, and field_name to match the errors you're getting on your site.
  9. the errors should go away and you can disable the module and remove it from your site.

Just a last, casual note for others: I know this super basic level of detail might seem heavy handed, but there's so much of fixing and maintaining Drupal sites that's obfuscated and confusing. The "how to build a drupal module" guides are good, but still don't link to an example repository or boilerplate to help people get started or see an end product. I'd just like to advocate for this level of clarity in the future. (soap box rant over).

dadderley’s picture

I took over some sites that had been migrated from drupal 7 and there were all kinds of relics left over from the migration.
This has been vexing for a long time.

My dblog reports were polluted with errors like this:
A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: taxonomy_term, bundle: migrate_example_wine_varieties, field name: field_variety_attributes

I followed your well written instructions and now the dblog page is free from these stupid errors.

Thank you rex.barkdoll!

vlad.dancer’s picture

Issue summary: View changes
vlad.dancer’s picture

We used code from #27 and deleted all weird things.
But I would also reccomend that if "bundle_field_map" ($map) is empty after unsetting:

$field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
$map = $field_map_kv_store->get($entity_type);
// Remove the field_dates field from the bundle field map for the page bundle.
unset($map[$field_name]['bundles'][$bundle]);
$field_map_kv_store->set($entity_type, $map);

then it is better to remove such record:

  if (empty($field_map_kv_store->get($entity_type))) {
    $field_map_kv_store->delete($entity_type);
  }

Alternatively/additionally I would recommend to search key_value table for leftovers:
SELECT `collection`, `name`, `value` FROM `key_value` WHERE `name` LIKE '%comment%' LIMIT 0,1000;
Like: state comment.maintain_entity_statistics b:1;

Anonymous’s picture

Thank you @rexbarkdoll #74 worked for me and indeed this was my first module ever.

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.

butterwise’s picture

I, too, inherited a site that was migrated from D7 to D9 which was plagued by a couple of these annoying errors. Thank you, @rex.barkdoll, for the thorough and easy to understand instructions in #74. Worked like a charm!

anybody’s picture

Same here as #80 so it would be quite useful to have a core cleanup tool for this.

koffer’s picture

I get some problem with a site migrated from Drupal 7 to Drupal 9 then to Drupal 10. I get a lot of error message about comments fields

Error like:
Field comment.comment_node_article.comment_body exists but is missing a corresponding field definition and may be misconfigured

I fix it creating a new field for comments and refreshing cache.

khurrami’s picture

Thanks a lot #74 worked for me as well

luksak’s picture

I improved the approach in #60 a bit:

function MODULE_update_9501() {

  $fields = [
    [
      'entity_type' => 'node',
      'bundle' => 'bundle_name',
      'field_name' => 'field_name',
    ],
  ];

  foreach($fields as $field){

    /** @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory */
    $key_value_factory = \Drupal::service('keyvalue');
    $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
    $map = $field_map_kv_store->get($field['entity_type']);

    // Remove the field_fpimage field from the bundle gallery_assist for the page bundle.
    unset($map[$field['field_name']]['bundles'][$field['bundle']]);

    $field_map_kv_store->set($field['entity_type'], $map);
  }
}
jrwest_webguy’s picture

#74 was very helpful for me as well. Thank you @junaidpv and @rex.barkdoll.

kmcgill7’s picture

Creating a hook from #25 and expanding it to include the approach from #60 cleared the error

amir jamshidi’s picture

#74 worked for me. thanks

mlncn’s picture

This comes up on so many sites we inherit as rescues of attempted migrations, so added the work from this issue to Migration Helpers module as a few functions available to use in an update hook or a deploy hook (not drush, at the moment anyway).

If there are safe-ish ways to automatically remove invalid configurations from entity definitions bundle_field_map i would happily experiment with them there.

finex’s picture

Hi, #66 and #74 solved the problem. Thank you very much :-)

priyaecs’s picture

Hi
#66 fixed the errors. Thanks junaidpv

koppie’s picture

Comment #66 is three years old, and yet we have no stable fix for this issue.

How about a module?

I've taken @junaidpv's excellent work and packaged it as a contrib module, ready to download with composer: https://www.drupal.org/project/update_config_entity

The only change I made was to add support for Drupal 11. Patches are welcome!

Roadmap:

  • In 10 days I can apply for Drupal security coverage for this new project. I will definitely opt in.
quietone’s picture

Status: Needs work » Active

This issue is a support request and there is no MR to work on, so changing status.

The Drupal Core issue queue is not the ideal place for support requests. The 'support request' option is there for filing support issues for contributed modules and themes. There are several support options listed on our support page (Community > Support at the top of Drupal.org) and there is Drupal Slack. You may get better replies in one of those places.

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.

quietone’s picture

Issue summary: View changes
Status: Active » Fixed

I updated the issue summary directing to the comments that offered solutions.

I am closing this per the guidance in Handle or refer a support request in an issue.

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.

Status: Fixed » Closed (fixed)

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

trigve hagen’s picture

Created a fix for this if you still need it. Thanks
https://www.drupal.org/project/module_cleanup