Problem/Motivation

I have a sub profile project of wxt. When I do a site install I get a message about missing config media.type.image. It is coming from the hook install (stacj trace below). I looked for the config and can find it in several places (optional in lightning_media), it isn't in wxt_ext_media. I tried in optional in wxt_ext_media and that didn't work. However, if I add it to install it seems to be ok. Not sure if this is a valid solution.

Steps to reproduce

- create a subprofile of wxt
- have a dependency on wxt_ext_media
- do a site install

In EntityType.php line 877:
                                                                   
  [LogicException]                                                 
  Missing bundle entity, entity type media_type, entity id image.  
                                                                   

Exception trace:
  at /var/www/html/core/lib/Drupal/Core/Entity/EntityType.php:877
 Drupal\Core\Entity\EntityType->getBundleConfigDependency() at /var/www/html/core/modules/language/src/Entity/ContentLanguageSettings.php:208
 Drupal\language\Entity\ContentLanguageSettings->calculateDependencies() at /var/www/html/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:318
 Drupal\Core\Config\Entity\ConfigEntityBase->preSave() at /var/www/html/core/modules/language/src/Entity/ContentLanguageSettings.php:167
 Drupal\language\Entity\ContentLanguageSettings->preSave() at /var/www/html/core/lib/Drupal/Core/Entity/EntityStorageBase.php:494
 Drupal\Core\Entity\EntityStorageBase->doPreSave() at /var/www/html/core/lib/Drupal/Core/Entity/EntityStorageBase.php:449
 Drupal\Core\Entity\EntityStorageBase->save() at /var/www/html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:263
 Drupal\Core\Config\Entity\ConfigEntityStorage->save() at /var/www/html/core/lib/Drupal/Core/Entity/EntityBase.php:339
 Drupal\Core\Entity\EntityBase->save() at /var/www/html/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:591
 Drupal\Core\Config\Entity\ConfigEntityBase->save() at /var/www/html/core/modules/content_translation/src/ContentTranslationManager.php:85
 Drupal\content_translation\ContentTranslationManager->setEnabled() at /var/www/html/profiles/wxt/modules/custom/wxt_translation/wxt_translation.module:29
 wxt_translation_enable_translation() at /var/www/html/profiles/wxt/modules/custom/wxt_ext/wxt_ext_media/wxt_ext_media.install:18
 wxt_ext_media_install() at n/a:n/a
 call_user_func_array() at /var/www/html/core/lib/Drupal/Core/Extension/ModuleHandler.php:392
 Drupal\Core\Extension\ModuleHandler->invoke() at /var/www/html/core/lib/Drupal/Core/Extension/ModuleInstaller.php:325
 Drupal\Core\Extension\ModuleInstaller->install() at /var/www/html/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
 Drupal\Core\ProxyClass\Extension\ModuleInstaller->install() at /var/www/html/core/includes/install.core.inc:1880
 _install_module_batch() at /var/www/html/core/includes/batch.inc:295
 _batch_process() at /var/www/html/core/includes/form.inc:950
 batch_process() at /var/www/html/core/includes/install.core.inc:650
 install_run_task() at /var/www/html/core/includes/install.core.inc:568
 install_run_tasks() at /var/www/html/core/includes/install.core.inc:118
 install_drupal() at /var/www/vendor/drush/drush/includes/drush.inc:213
 drush_call_user_func_array() at /var/www/vendor/drush/drush/includes/drush.inc:197
 drush_op() at /var/www/vendor/drush/drush/src/Commands/core/SiteInstallCommands.php:149
 Drush\Commands\core\SiteInstallCommands->install() at n/a:n/a
 call_user_func_array() at /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php:257
 Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() at /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php:212
 Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() at /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php:176
 Consolidation\AnnotatedCommand\CommandProcessor->process() at /var/www/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:311
 Consolidation\AnnotatedCommand\AnnotatedCommand->execute() at /var/www/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/vendor/symfony/console/Application.php:1027
 Symfony\Component\Console\Application->doRunCommand() at /var/www/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /var/www/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /var/www/vendor/drush/drush/src/Runtime/Runtime.php:118
 Drush\Runtime\Runtime->doRun() at /var/www/vendor/drush/drush/src/Runtime/Runtime.php:49
 Drush\Runtime\Runtime->run() at /var/www/vendor/drush/drush/drush.php:72
 require() at /var/www/vendor/drush/drush/drush:4

Proposed resolution

Add the media.type.image config from lightning into the install config of wxt_wxt_media

Remaining tasks

review?

User interface changes

none

API changes

none

Data model changes

none

CommentFileSizeAuthor
#2 3188088-2.patch537 bytesnatew
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

natew created an issue. See original summary.

natew’s picture

FileSize
537 bytes
sylus’s picture

Let me check this out,

wxt_ext_media has a dependency on lightning_media_image which itself has the media.type.image.yml under config/optional.

So this shouldn't need to be done.

sylus’s picture

Okay I finally understand this, the problem is a long standing one with Drupal core it just really seems you can't do everything in the same batch as dependency resolution has some issues. We actually solved this in the 4.0.x line which is why people don't seem to be having and dep problems any more.

Lets take a look at the following:

[notice] Starting Drupal installation. This takes a while.
 [notice] Performed install task: install_select_language
 [notice] Performed install task: install_select_profile
 [notice] Performed install task: install_load_profile
 [notice] Performed install task: install_verify_requirements
 [notice] Performed install task: install_settings_form
 [notice] Performed install task: install_verify_database_ready
 [notice] Performed install task: install_base_system
 [notice] Performed install task: install_bootstrap_full
 [notice] Performed install task: install_profile_modules
 [notice] Performed install task: install_profile_themes
 [notice] Performed install task: install_install_profile
 [notice] Translations imported: 9187 added, 0 updated, 0 removed.
 [notice] Performed install task: install_import_translations
 [notice] Performed install task: wxt_extension_configure_form
 [notice] Performed install task: install_configure_form
 [notice] metatag.metatag_defaults.taxonomy_term rewritten by wxt_ext_metatag
 [notice] metatag.metatag_defaults.global rewritten by wxt_ext_metatag
 [notice] metatag.metatag_defaults.user rewritten by wxt_ext_metatag
 [notice] metatag.metatag_defaults.node rewritten by wxt_ext_metatag
 [notice] field.storage.node.field_blog_tags rewritten by wxt_ext_blog
 [notice] core.entity_form_display.node.blog_post.default rewritten by wxt_ext_blog
 [notice] node.type.blog_post rewritten by wxt_ext_blog
 [notice] field.field.node.blog_post.field_blog_tags rewritten by wxt_ext_blog
 [notice] core.entity_view_display.node.blog_post.default rewritten by wxt_ext_blog
 [notice] views.view.blog rewritten by wxt_ext_blog
 [notice] field.field.node.blog_post.field_blog_comments rewritten by wxt_ext_blog
 [notice] menu_breadcrumb.settings rewritten by wxt_ext_breadcrumb
 [notice] editor.editor.rich_text rewritten by wxt_ext_editor
 [notice] image.style.linkit_result_thumbnail rewritten by wxt_ext_editor
 [notice] filter.format.rich_text rewritten by wxt_ext_editor
 [notice] linkit.linkit_profile.default rewritten by wxt_ext_editor
 [notice] fontawesome.settings rewritten by wxt_ext_fontawesome
 [notice] pathauto.pattern.group_content rewritten by wxt_ext_group
 [notice] group.settings rewritten by wxt_ext_group
 [notice] field.storage.node.layout_builder__layout rewritten by wxt_ext_layout
 [notice] field.storage.node.layout_selection rewritten by wxt_ext_layout
 [notice] field.storage.node.layout_builder__translation rewritten by wxt_ext_layout
 [notice] layout_library.layout.page_two_column rewritten by wxt_ext_layout
 [notice] core.entity_form_display.node.landing_page.default rewritten by wxt_ext_landing_page
 [notice] field.field.node.landing_page.layout_builder__layout rewritten by wxt_ext_landing_page
 [notice] field.field.node.landing_page.layout_builder__translation rewritten by wxt_ext_landing_page
 [notice] core.entity_view_display.node.landing_page.full rewritten by wxt_ext_landing_page
 [notice] field.field.node.landing_page.layout_selection rewritten by wxt_ext_landing_page
 [notice] core.entity_form_display.node.page.default rewritten by wxt_ext_page
 [notice] core.entity_view_display.node.page.default rewritten by wxt_ext_page
 [notice] node.type.page rewritten by wxt_ext_page
 [notice] field.field.node.page.layout_selection rewritten by wxt_ext_page
 [notice] core.entity_form_display.node.landing_page.default rewritten by wxt_ext_queue
 [notice] views.view.blocks rewritten by wxt_ext_queue
 [notice] system.theme rewritten by wxt_ext_theme
 [notice] node.settings rewritten by wxt_ext_theme
 [notice] user.settings rewritten by wxt_ext_user
 [notice] field.field.node.webform.webform rewritten by wxt_ext_webform
 [notice] core.entity_view_display.node.webform.default rewritten by wxt_ext_webform
 [notice] field.field.node.webform.body rewritten by wxt_ext_webform
 [notice] node.type.webform rewritten by wxt_ext_webform
 [notice] field.storage.node.webform rewritten by wxt_ext_webform
 [notice] core.entity_form_display.node.webform.default rewritten by wxt_ext_webform
 [notice] core.entity_view_display.node.webform.teaser rewritten by wxt_ext_webform
 [notice] Translation file not found: http://ftp.drupal.org/files/translations/9.x/drupal/drupal-9.0.9.fr.po.
 [notice] Translation file not found: http://ftp.drupal.org/files/translations/9.x/drupal/drupal-9.0.9.fr.po.
 [notice] Translation file not found: http://ftp.drupal.org/files/translations/9.x/drupal/drupal-9.0.9.fr.po.
 [notice] Translation file not found: http://ftp.drupal.org/files/translations/9.x/drupal/drupal-9.0.9.fr.po.
 [notice] Translation file not found: http://ftp.drupal.org/files/translations/9.x/drupal/drupal-9.0.9.fr.po.
 [notice] Performed install task: wxt_install_extensions
 [notice] Performed install task: install_finish_translations
 [notice] Cron run completed.
 [notice] Performed install task: install_finished
 [notice] Performed install task: wxt_import_language_config
 [success] Installation complete.

real    3m12.651s

Particularly take note of these lines:

 [notice] Performed install task: install_profile_modules
 [notice] Performed install task: install_profile_themes
 [notice] Performed install task: install_install_profile
 [notice] Translations imported: 9187 added, 0 updated, 0 removed.
 [notice] Performed install task: install_import_translations
 [notice] Performed install task: wxt_extension_configure_form
 [notice] Performed install task: install_configure_form

What we do and other distributions like Lightning, DeGov, and Open Social is we let the install profile install just very simple core modules as a base, and then finish the installation of the profile, themes, and core set of modules.

Then we create another batch step that installs the rest of the modules once the base install is done, this both fixes long standing dependency issues and in general follows actually what a person would do once they install Drupal and then install modules afterwards. This both aligns with that workflow, fixes dependency issues, and allows for us to make the remaining modules optional.

The problem with your subprofile is that you are trying to do things too early in the bootstrap and instead should do your config and module enablement in the wxt_extension_configure_form step once the base of the site and core is fully installed.

So here is what I would like you to try to proof this works!

STEP 1

Note I removed the install of CCEI core below:

name: 'CCEI'
description: 'A Drupal distribution for CCEI created to leverage the Web Experience Toolkit.'
type: profile
core_version_requirement: ^8.8 || ^9
distribution:
  name: 'CCEI'

# Base profile
base profile: wxt

# Exclude from base profile
exclude:
  - lightning_api
  - lightning_contact_form
  - lightning_roles
  - lightning_scheduled_updates
  - lightning_search

# Language
keep_english: true

themes:
  - bartik
  - seven
  - claro
  - ccei_bootstrap

STEP 2

Add the following file `ccei_core.wxt_extension.yml` to CCEI Core below:

name: CCEI Core
description: CCEI Core
default: false

Now I think you can just pass "wxt_extension_configure_form.select_all=TRUE" so all optional modules are enabled or just set the default: true for the above file and only this module should be enabled. It will be important though if any of your modules require any wxt_ext_* dependencies that you declare that explicit dependency.

For a temporary hammer approach you could set ccei_core to have a dependency on wxt_ext itself set the default to true in the above file and then see if everything is working before you go more granular in your deps. You wouldn't need the drush flag since you set default to true.

Basically we want you to have all of your custom stuff in our next batch step technically after Drupal is installed, and this will resolve a whole host of problems arounds dep and very close to people just enabling modules etc post install in the GUI :D

I hope this makes sense :D

sylus’s picture

Title: sub profile install of ext_ext_media fails with image media missing » Sub profile install of wxt_ext_* components
natew’s picture

Title: Sub profile install of wxt_ext_* components » sub profile install of ext_ext_media fails with image media missing
Status: Active » Closed (outdated)

Thanks Will for looking at this and helping, going to close this as your solution worked in the latest 4.x-dev!

sylus’s picture

Title: sub profile install of ext_ext_media fails with image media missing » Subprofile install of components
sylus’s picture

Title: Subprofile install of components » Subprofile install of modules and wxt_extensions