Fatal Errors when Generating and enforcing from existing module config/optional with DDEV

Created on 12 July 2023, 12 months ago

Problem/Motivation

I cannot enforce the config that was already in my custom module's config/optional in bulk with the "Generate from modules" button.

Steps to reproduce

DDEV drupal-recommended install with D10.1
Follow the installation and "Add Config Enforce to a project" steps from your consensus.enterprises docs
Notice that at the last step "Enforce these config_enforce.devel settings by checking the Enforce Config" on my dev module, saving will return error TypeError: ksort(): Argument #1 ($array) must be of type array, null given in ksort() (line 136 of /var/www/html/web/modules/contrib/config_enforce_devel/src/EnforcedConfigRegistry.php)., but a page reload (with form resubmission) seems to work fine.
Then go to Enforce Configs tab and click on Generate from modules:
Select read-only enforcement level, my custom module (not the dev one enforcing the config_enforce_devel settings), and all of its optional configurations, click save. Everything seems to be enforced (green) but doing a ddev drush cr to "Apply enforced configs" as in your docs leads to these errore in the terminal:

ddev drush cr
PHP Fatal error:  Uncaught Error: Call to undefined method Drupal\config_enforce\EnforcedConfigRegistry::deleteEnforcedConfigs() in /var/www/html/web/modules/contrib/config_enforce_devel/src/EnforcedConfigCollection.php:132
Stack trace:
#0 /var/www/html/web/modules/contrib/config_enforce_devel/src/EventSubscriber/ConfigDeleteSubscriber.php(56): Drupal\config_enforce_devel\EnforcedConfigCollection->deleteEnforcedConfigs(Array)
#1 [internal function]: Drupal\config_enforce_devel\EventSubscriber\ConfigDeleteSubscriber->onConfigDelete(Object(Drupal\Core\Config\ConfigCrudEvent), 'config.delete', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#2 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\Core\Config\ConfigCrudEvent), 'config.delete', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#3 /var/www/html/web/core/lib/Drupal/Core/Config/Config.php(246): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\Core\Config\ConfigCrudEvent), 'config.delete')
#4 /var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(232): Drupal\Core\Config\Config->delete()
#5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(456): Drupal\Core\Config\Entity\ConfigEntityStorage->doDelete(Array)
#6 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(347): Drupal\Core\Entity\EntityStorageBase->delete(Array)
#7 /var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(384): Drupal\Core\Entity\EntityBase->delete()
#8 /var/www/html/web/core/modules/field/src/FieldConfigStorage.php(96): Drupal\Core\Config\Entity\ConfigEntityStorage->importDelete('field.field.tax...', Object(Drupal\Core\Config\Config), Object(Drupal\Core\Config\Config))
#9 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(1056): Drupal\field\FieldConfigStorage->importDelete('field.field.tax...', Object(Drupal\Core\Config\Config), Object(Drupal\Core\Config\Config))
#10 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(842): Drupal\Core\Config\ConfigImporter->importInvokeOwner('', 'delete', 'field.field.tax...')
#11 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(663): Drupal\Core\Config\ConfigImporter->processConfiguration('', 'delete', 'field.field.tax...')
#12 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(561): Drupal\Core\Config\ConfigImporter->processConfigurations(Array)
#13 /var/www/html/web/modules/contrib/config_enforce/src/ConfigImporter.php(90): Drupal\Core\Config\ConfigImporter->doSyncStep('processConfigur...', Array)
#14 /var/www/html/web/modules/contrib/config_enforce/src/ConfigImporter.php(48): Drupal\config_enforce\ConfigImporter->doImport(Object(Drupal\Core\Config\StorageComparer))
#15 /var/www/html/web/modules/contrib/config_enforce/src/ConfigEnforcer.php(80): Drupal\config_enforce\ConfigImporter->importConfig(Array)
#16 /var/www/html/web/modules/contrib/config_enforce/config_enforce.module(51): Drupal\config_enforce\ConfigEnforcer->enforceConfigs()
#17 [internal function]: config_enforce_rebuild()
#18 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array(Object(Closure), Array)
#19 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'config_enforce')
#20 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\Core\Extension\ModuleHandler->invokeAllWith('rebuild', Object(Closure))
#21 /var/www/html/web/core/includes/common.inc(510): Drupal\Core\Extension\ModuleHandler->invokeAll('rebuild')
#22 /var/www/html/web/core/includes/utility.inc(41): drupal_flush_all_caches(Object(Drupal\Core\DrupalKernel))
#23 /var/www/html/vendor/drush/drush/src/Commands/core/CacheCommands.php(228): drupal_rebuild(Object(Composer\Autoload\ClassLoader), Object(Symfony\Component\HttpFoundation\Request))
#24 [internal function]: Drush\Commands\core\CacheCommands->rebuild(Array)
#25 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array)
#26 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#27 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#28 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#29 /var/www/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/html/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/html/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /var/www/html/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /var/www/html/vendor/drush/drush/drush.php(79): Drush\Runtime\Runtime->run(Array)
#36 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
#37 /var/www/html/vendor/bin/drush(120): include('/var/www/html/v...')
#38 {main}
  thrown in /var/www/html/web/modules/contrib/config_enforce_devel/src/EnforcedConfigCollection.php on line 132

Fatal error: Uncaught Error: Call to undefined method Drupal\config_enforce\EnforcedConfigRegistry::deleteEnforcedConfigs() in /var/www/html/web/modules/contrib/config_enforce_devel/src/EnforcedConfigCollection.php:132
Stack trace:
#0 /var/www/html/web/modules/contrib/config_enforce_devel/src/EventSubscriber/ConfigDeleteSubscriber.php(56): Drupal\config_enforce_devel\EnforcedConfigCollection->deleteEnforcedConfigs(Array)
#1 [internal function]: Drupal\config_enforce_devel\EventSubscriber\ConfigDeleteSubscriber->onConfigDelete(Object(Drupal\Core\Config\ConfigCrudEvent), 'config.delete', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#2 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\Core\Config\ConfigCrudEvent), 'config.delete', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#3 /var/www/html/web/core/lib/Drupal/Core/Config/Config.php(246): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\Core\Config\ConfigCrudEvent), 'config.delete')
#4 /var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(232): Drupal\Core\Config\Config->delete()
#5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(456): Drupal\Core\Config\Entity\ConfigEntityStorage->doDelete(Array)
#6 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(347): Drupal\Core\Entity\EntityStorageBase->delete(Array)
#7 /var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(384): Drupal\Core\Entity\EntityBase->delete()
#8 /var/www/html/web/core/modules/field/src/FieldConfigStorage.php(96): Drupal\Core\Config\Entity\ConfigEntityStorage->importDelete('field.field.tax...', Object(Drupal\Core\Config\Config), Object(Drupal\Core\Config\Config))
#9 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(1056): Drupal\field\FieldConfigStorage->importDelete('field.field.tax...', Object(Drupal\Core\Config\Config), Object(Drupal\Core\Config\Config))
#10 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(842): Drupal\Core\Config\ConfigImporter->importInvokeOwner('', 'delete', 'field.field.tax...')
#11 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(663): Drupal\Core\Config\ConfigImporter->processConfiguration('', 'delete', 'field.field.tax...')
#12 /var/www/html/web/core/lib/Drupal/Core/Config/ConfigImporter.php(561): Drupal\Core\Config\ConfigImporter->processConfigurations(Array)
#13 /var/www/html/web/modules/contrib/config_enforce/src/ConfigImporter.php(90): Drupal\Core\Config\ConfigImporter->doSyncStep('processConfigur...', Array)
#14 /var/www/html/web/modules/contrib/config_enforce/src/ConfigImporter.php(48): Drupal\config_enforce\ConfigImporter->doImport(Object(Drupal\Core\Config\StorageComparer))
#15 /var/www/html/web/modules/contrib/config_enforce/src/ConfigEnforcer.php(80): Drupal\config_enforce\ConfigImporter->importConfig(Array)
#16 /var/www/html/web/modules/contrib/config_enforce/config_enforce.module(51): Drupal\config_enforce\ConfigEnforcer->enforceConfigs()
#17 [internal function]: config_enforce_rebuild()
#18 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array(Object(Closure), Array)
#19 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'config_enforce')
#20 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(416): Drupal\Core\Extension\ModuleHandler->invokeAllWith('rebuild', Object(Closure))
#21 /var/www/html/web/core/includes/common.inc(510): Drupal\Core\Extension\ModuleHandler->invokeAll('rebuild')
#22 /var/www/html/web/core/includes/utility.inc(41): drupal_flush_all_caches(Object(Drupal\Core\DrupalKernel))
#23 /var/www/html/vendor/drush/drush/src/Commands/core/CacheCommands.php(228): drupal_rebuild(Object(Composer\Autoload\ClassLoader), Object(Symfony\Component\HttpFoundation\Request))
#24 [internal function]: Drush\Commands\core\CacheCommands->rebuild(Array)
#25 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array)
#26 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#27 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#28 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#29 /var/www/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /var/www/html/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /var/www/html/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /var/www/html/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /var/www/html/vendor/drush/drush/drush.php(79): Drush\Runtime\Runtime->run(Array)
#36 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
#37 /var/www/html/vendor/bin/drush(120): include('/var/www/html/v...')
#38 {main}
  thrown in /var/www/html/web/modules/contrib/config_enforce_devel/src/EnforcedConfigCollection.php on line 132
 [warning] Drush command terminated abnormally.
Failed to run drush cr: exit status 1

A second run of ddev drush cr will not produce errors, but the site will still be completely broken (no page accessible other than unstyled /update.php). Not even a drush site:install nor a ddev restart would fix!!

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇹Italy kopeboy Mainland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024