Problem/Motivation

wodby@php.container:/var/www/lom $ drush cex
 [notice] The foo bundle (entity type: paragraph) was deleted. As a result, the bar entity reference revisions field (entity_type: node, bundle: rfq) no longer specifies a specific target bundle. The field will now accept any bundle and may need to be adjusted.
 [success] Configuration successfully exported to ../config/sday_lom_rf/sync.

But foo bundle is still exists. No problem appears. Only this notice.

EntityReferenceRevisionsItem.php:445, Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::onDependencyRemoval()
FieldConfigBase.php:263, Drupal\field\Entity\FieldConfig->onDependencyRemoval()
ConfigManager.php:466, Drupal\Core\Config\ConfigManager->callOnDependencyRemoval()
ConfigManager.php:329, Drupal\Core\Config\ConfigManager->getConfigEntitiesToChangeOnDependencyRemoval()
ConfigSplitManager.php:300, Drupal\config_split\ConfigSplitManager->splitPreview()
ConfigSplitManager.php:234, Drupal\config_split\ConfigSplitManager->exportTransform()
SplitImportExportSubscriber.php:82, Drupal\config_split\EventSubscriber\SplitImportExportSubscriber->exportDefaultPriority()
ContainerAwareEventDispatcher.php:142, call_user_func:{/var/www/lom/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:142}()
ContainerAwareEventDispatcher.php:142, Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
ExportStorageManager.php:88, Drupal\Core\Config\ExportStorageManager->getStorage()
ManagedStorage.php:146, Drupal\Core\Config\ManagedStorage->getStorage()
ManagedStorage.php:134, Drupal\Core\Config\ManagedStorage->getCollectionName()
ConfigCommands.php:554, Drush\Drupal\Commands\config\ConfigCommands::copyConfig()
ConfigExportCommands.php:175, Drush\Drupal\Commands\config\ConfigExportCommands->doExport()
ConfigExportCommands.php:117, Drush\Drupal\Commands\config\ConfigExportCommands->export()
CommandProcessor.php:257, call_user_func_array:{/var/www/lom/vendor/consolidation/annotated-command/src/CommandProcessor.php:257}()
CommandProcessor.php:257, Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
CommandProcessor.php:212, Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
CommandProcessor.php:176, Consolidation\AnnotatedCommand\CommandProcessor->process()
AnnotatedCommand.php:313, Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
Command.php:255, Consolidation\AnnotatedCommand\AnnotatedCommand->run()
Application.php:1027, Drush\Application->doRunCommand()
Application.php:273, Drush\Application->doRun()
Application.php:149, Drush\Application->run()
Runtime.php:118, Drush\Runtime\Runtime->doRun()
Runtime.php:48, Drush\Runtime\Runtime->run()
drush.php:72, eval()
1:3, eval()
drush:21, {main}()

Drupal core: 9.2.8-dev

Command icon Show commands

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

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

Comments

super_romeo created an issue. See original summary.

super_romeo’s picture

Issue summary: View changes
super_romeo’s picture

Title: The foo bundle (entity type: paragraph) was deleted. As a result, the bar entity reference revisions field (entity_type: node, bundle: rfq) no longer specifies a specific target bundle » Notice: The foo bundle was deleted. As a result, the bar entity reference revisions field no longer specifies a specific target bundle
b_sharpe’s picture

I'm also seeing this, I believe as a result of the config being in a split

shagel’s picture

Is there any solution here to avoid this ? I get this too.
I have a multisite setup (2 sites), site one has a quiz content type and a field that references a quiz_answer paragraph.
Since the site 2 doesnt have that content type and doesnt have the paragraph, i added this to full split.
I do a
drush @project1_alias si --existing-config -y
than
drush @project1_alias cex
and i get this notice
[notice] The Quiz answer bundle (entity type: paragraph) was deleted. As a result, the field_paragraphs entity reference revisions field (entity_type: node, bundle: quiz_question) no longer specifies a specific target bundle. The field will now accept any bundle and may need to be adjusted.
When i login to the backend everything seems fine.

alexpott’s picture

Yep this message is occurring due to config split. The implementation in \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::onDependencyRemoval() is incorrect. This method cannot log a message at this point because it has no idea if this will occur on not. The config system can do a dry to determine what entities will change when you remove one. Config split uses this to determine is config needs to be split.

The fix here is to move the message to post save hook and set a flag in the onDependencyRemoval() method. Or something like that.

alexpott’s picture

Also in the most basic usage of the entity reference revisions this message is actually wrong.

If you follow these steps:

  • install standard
  • Enable entity reference revisions
  • Create a node type called Test
  • Create an entity reference revisions field on Article and let it reference nodes of the type Test
  • Delete the node type test.

Then view the log messages you will see 3x the message from \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::onDependencyRemoval
The Test bundle (entity type: node) was deleted. As a result, the field_err entity reference revisions field (entity_type: node, bundle: article) no longer specifies a specific target bundle. The field will now accept any bundle and may need to be adjusted.

Then you will see the following message from the field module
The field_err entity reference field (entity_type: node, bundle: article) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.

The last message is correct in this situation. My guess is that the message might be true for certain handlers but it is not true for the default handler provided by core. I think the correct thing to do here is to remove the message from entity_reference_revisions and if it is true with the handler from paragraphs then do something there because atm this message is wrong more often than it is correct. Note if you cancel deleting the content type Test during the delete you will still have 1x the message in the log because of the dry run.

alexpott’s picture

Status: Active » Needs review
alexpott’s picture

If we really want to add this message then we need to copy the field module and do something in hook_field_config_presave() or hook_field_config_update() but as detailed in #7 I'm not sure about this.

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

  • Berdir committed d1e30f73 on 8.x-1.x authored by alexpott
    Issue #3247178 by alexpott: Notice: The foo bundle was deleted. As a...
berdir’s picture

Status: Needs review » Fixed

This was initially copied from core, which moved it in #2925913: EntityReferenceItem logs critical errors in onDependencyRemoval(). field_field_config_presave() also acts on ERR field types, which I'm not sure is really desirable(it explicitly supports subclasses of EntityReferenceItem) but considering that, it seems fine to remove it.

Also, \Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval() is a similarly flawed remaining case in core that still logs stuff in onDependencyRemoval().

You're likely also getting this message on the manage permissions page of such a target bundle, see #3384600: [backport] Don't hide permissions local tasks on bundles when no permissions are defined (I may or may not be trying to lure @alexpott towards that issue)

Merged.

Status: Fixed » Closed (fixed)

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