Hello,

Thank you very much for the D8 version.

I just started using it and I encountered a config problem when building my website from config exported in features.

Here is the code: https://github.com/Drupal-FR/site-drupalfr/tree/8.x-1.x/www/profiles/cus...

In one of the features, drupalfr_planet, I put the feed type and the content type associated with the fields, etc. When rebuilding from scratch this is the error I obtained:

LogicException: Missing bundle entity, entity type node_type, entity id planet. in /project/www/core/lib/Drupal/Core/Entity/EntityType.php:866                                                                                                                          [error]
Stack trace:
#0 /project/www/core/lib/Drupal/Core/Field/FieldConfigBase.php(239): Drupal\Core\Entity\EntityType->getBundleConfigDependency('planet')
#1 /project/www/core/modules/field/src/Entity/FieldConfig.php(181): Drupal\Core\Field\FieldConfigBase->calculateDependencies()
#2 /project/www/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(346): Drupal\field\Entity\FieldConfig->calculateDependencies()
#3 /project/www/core/modules/field/src/Entity/FieldConfig.php(174): Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object(Drupal\field\FieldConfigStorage))
#4 /project/www/core/lib/Drupal/Core/Entity/EntityStorageBase.php(434): Drupal\field\Entity\FieldConfig->preSave(Object(Drupal\field\FieldConfigStorage))
#5 /project/www/core/lib/Drupal/Core/Entity/EntityStorageBase.php(389): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\field\Entity\FieldConfig))
#6 /project/www/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(259): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\field\Entity\FieldConfig))
#7 /project/www/core/lib/Drupal/Core/Entity/Entity.php(364): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\field\Entity\FieldConfig))
#8 /project/www/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(637): Drupal\Core\Entity\Entity->save()
#9 /project/www/modules/contrib/feeds/src/Feeds/Processor/EntityProcessorBase.php(410): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#10 /project/www/modules/contrib/feeds/src/Feeds/Processor/EntityProcessorBase.php(377): Drupal\feeds\Feeds\Processor\EntityProcessorBase->prepareFeedsItemField()
#11 /project/www/modules/contrib/feeds/src/Entity/FeedType.php(445): Drupal\feeds\Feeds\Processor\EntityProcessorBase->onFeedTypeSave(true)
#12 /project/www/core/lib/Drupal/Core/Entity/EntityStorageBase.php(434): Drupal\feeds\Entity\FeedType->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))
#13 /project/www/core/lib/Drupal/Core/Entity/EntityStorageBase.php(389): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\feeds\Entity\FeedType))
#14 /project/www/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(259): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\feeds\Entity\FeedType))
#15 /project/www/core/lib/Drupal/Core/Entity/Entity.php(364): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\feeds\Entity\FeedType))
#16 /project/www/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(637): Drupal\Core\Entity\Entity->save()
#17 /project/www/core/lib/Drupal/Core/Config/ConfigInstaller.php(321): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#18 /project/www/core/lib/Drupal/Core/Config/ConfigInstaller.php(125): Drupal\Core\Config\ConfigInstaller->createConfiguration('', Array)
#19 /project/www/modules/contrib/features/src/ProxyClass/FeaturesConfigInstaller.php(74): Drupal\Core\Config\ConfigInstaller->installDefaultConfig('module', 'drupalfr_planet')
#20 /project/www/core/lib/Drupal/Core/Extension/ModuleInstaller.php(248): Drupal\features\ProxyClass\FeaturesConfigInstaller->installDefaultConfig('module', 'drupalfr_planet')
#21 /project/www/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install(Array, false)
#22 /project/www/core/includes/install.core.inc(1781): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array, false)
#23 /project/www/core/includes/batch.inc(252): _install_module_batch('drupalfr_planet', 'Article du plan...', Array)
#24 /project/www/core/includes/form.inc(870): _batch_process()
#25 /project/www/core/includes/install.core.inc(615): batch_process(Object(Drupal\Core\Url), Object(Drupal\Core\Url))
#26 /project/www/core/includes/install.core.inc(536): install_run_task(Array, Array)
#27 /project/www/core/includes/install.core.inc(115): install_run_tasks(Array)
#28 /project/www/vendor/drush/drush/includes/drush.inc(726): install_drupal(Object(Composer\Autoload\ClassLoader), Array)
#29 /project/www/vendor/drush/drush/includes/drush.inc(711): drush_call_user_func_array('install_drupal', Array)
#30 /project/www/vendor/drush/drush/commands/core/drupal/site_install.inc(80): drush_op('install_drupal', Object(Composer\Autoload\ClassLoader), Array)
#31 /project/www/vendor/drush/drush/commands/core/site_install.drush.inc(247): drush_core_site_install_version('drupalfr', Array)
#32 /project/www/vendor/drush/drush/includes/command.inc(373): drush_core_site_install('drupalfr')
#33 /project/www/vendor/drush/drush/includes/command.inc(224): _drush_invoke_hooks(Array, Array)
#34 /project/www/vendor/drush/drush/includes/command.inc(192): drush_command('drupalfr')
#35 /project/www/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#36 /project/www/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#37 /project/www/vendor/drush/drush/drush.php(12): drush_main()
#38 {main}

"planet" is the machine name of the node type created by this feed type.

So I tried to separate the feed type and the content type in distinct module and after some tries, it worked.

This is the dependency I found: drupalfr_planet_feed (provides the feed type) depends on drupalfr_planet (provides the content type)

I tried to put the config of drupalfr_planet_feed into drupalfr_planet (because I originally wanted one module) and I added the following config dependency in feeds.feed_type.planet_feed_rss.yml

dependencies:
  config:
    - node.type.planet

And now it works during the build. The content type is imported before the feed type.

Note: the last try of adding manually the config dependency is not commited in the git repository.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grimreaper created an issue. See original summary.

MegaChriz’s picture

#2926047: Config dependencies missing from feed_type configuration was closed as a duplicate.

Important information from there:

  • Config-import (drush cim) fails with feed type configurations if configured entity type is not imported before feed type is being imported.
  • The class FeedType should override the methods calculateDependencies() and/or calculatePluginDependencies().
  • Perhaps we need a dependency on each field used in the mapping as well. This can be handled in #2854914: Deleted Target Field Throws Fatal Error.

This issue should focus on defining a dependency on the entity type (and bundle) used by the processor.

mikran’s picture

This issue should focus on defining a dependency on the entity type (and bundle) used by the processor.

Here is a patch that adds dependecy on entity bundles. I believe that the dependency on entity type is already there. I added DependencyTrait to the PluginBase as I think it is much cleaner way to add these dependencies. But this patch does not do any unrelated refactoring.

MegaChriz’s picture

@mikran
Thanks for working on this! I have been working on field dependencies as well in #2854914: Deleted Target Field Throws Fatal Error and I believe that the last patch that I posted there fixes that issue. I hope that the patches work well together. There is a comment in there that the feed type should get deleted when the used entity bundle gets deleted. I was thinking that could go into this issue as well. It would require though that the patch from the other issue gets committed first.

Maybe you want to add a test for this issue as well?

Status: Needs review » Needs work

The last submitted patch, 3: add-dependency-on-entity-bundle-2787565-3.patch, failed testing. View results

MegaChriz’s picture

The tests failure more or less proved that the patch works, haha!

Here is a new patch that adds a test: it tested that the feed type is removed when the entity bundle is removed.

The last submitted patch, 6: feeds-add-dependency-on-entity-bundle-2787565-6-tests-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • MegaChriz committed 878348b on 8.x-3.x authored by mikran
    Issue #2787565 by MegaChriz, mikran: Fixed missing config dependency to...
MegaChriz’s picture

Status: Needs review » Fixed

Committed #6.

Status: Fixed » Closed (fixed)

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