From f91bfe6cdcc00145f8b9ebc814337be4abe9dbc5 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick <matt.grasmick@gmail.com> Date: Mon, 19 Jun 2017 14:01:20 -0400 Subject: [PATCH 1/4] Fixes #1675: Use cm.core.key everywhere. --- src/Robo/Commands/Setup/ConfigCommand.php | 36 +++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/Robo/Commands/Setup/ConfigCommand.php b/src/Robo/Commands/Setup/ConfigCommand.php index cabf905b9..a447c245f 100644 --- a/src/Robo/Commands/Setup/ConfigCommand.php +++ b/src/Robo/Commands/Setup/ConfigCommand.php @@ -68,18 +68,7 @@ public function import() { $task->run(); $this->checkFeaturesOverrides(); - - // Check for configuration overrides. - if (!$this->getConfigValue('cm.allow-overrides')) { - $this->say("Checking for config overrides..."); - $config_overrides = $this->taskDrush() - ->assume(FALSE) - ->drush("cex") - ->arg('sync'); - if (!$config_overrides->run()->wasSuccessful()) { - throw new BltException("Configuration in the database does not match configuration on disk. You must re-export configuration to capture the changes. This could also indicate a problem with the import process, such as changed field storage for a field with existing content. To permit configuration overrides, set cm.allow-overrides to true in blt/project.yml."); - } - } + $this->checkConfigOverrides($cm_core_key); $result = $this->invokeHook('post-config-import'); @@ -110,7 +99,7 @@ protected function importConfigSplit($task, $cm_core_key) { $core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml'; if (file_exists($core_config_file)) { $task->drush("pm-enable")->arg('config_split'); - $task->drush("config-import")->arg('sync'); + $task->drush("config-import")->arg($cm_core_key); } } @@ -167,4 +156,25 @@ protected function checkFeaturesOverrides() { } } + /** + * Checks whether core config is overridden. + * + * @param string $cm_core_key + * + * @throws \Acquia\Blt\Robo\Exceptions\BltException + */ + protected function checkConfigOverrides($cm_core_key) { + // Check for configuration overrides. + if (!$this->getConfigValue('cm.allow-overrides')) { + $this->say("Checking for config overrides..."); + $config_overrides = $this->taskDrush() + ->assume(FALSE) + ->drush("cex") + ->arg($cm_core_key); + if (!$config_overrides->run()->wasSuccessful()) { + throw new BltException("Configuration in the database does not match configuration on disk. You must re-export configuration to capture the changes. This could also indicate a problem with the import process, such as changed field storage for a field with existing content. To permit configuration overrides, set cm.allow-overrides to true in blt/project.yml."); + } + } + } + } From 84adf61ef10619157646c205e449971eddc28b4c Mon Sep 17 00:00:00 2001 From: Matthew Grasmick <matt.grasmick@gmail.com> Date: Mon, 19 Jun 2017 14:10:35 -0400 Subject: [PATCH 2/4] PHPCS fix. --- src/Robo/Commands/Setup/ConfigCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Robo/Commands/Setup/ConfigCommand.php b/src/Robo/Commands/Setup/ConfigCommand.php index a447c245f..02cedd89b 100644 --- a/src/Robo/Commands/Setup/ConfigCommand.php +++ b/src/Robo/Commands/Setup/ConfigCommand.php @@ -164,7 +164,7 @@ protected function checkFeaturesOverrides() { * @throws \Acquia\Blt\Robo\Exceptions\BltException */ protected function checkConfigOverrides($cm_core_key) { - // Check for configuration overrides. + // Check for configuration overrides. if (!$this->getConfigValue('cm.allow-overrides')) { $this->say("Checking for config overrides..."); $config_overrides = $this->taskDrush() From d6edb28fb80c0e23b0635f6ea68f316f0b78cbd8 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick <matt.grasmick@gmail.com> Date: Mon, 19 Jun 2017 14:13:52 -0400 Subject: [PATCH 3/4] Adding more useful debug output. --- src/Robo/Commands/Setup/ConfigCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Robo/Commands/Setup/ConfigCommand.php b/src/Robo/Commands/Setup/ConfigCommand.php index 02cedd89b..0630f9bf5 100644 --- a/src/Robo/Commands/Setup/ConfigCommand.php +++ b/src/Robo/Commands/Setup/ConfigCommand.php @@ -29,6 +29,7 @@ public function update() { public function import() { $strategy = $this->getConfigValue('cm.strategy'); $cm_core_key = $this->getConfigValue('cm.core.key'); + $this->logConfig($this->getConfigValue('cm'), 'cm'); if ($strategy != 'none') { $this->invokeHook('pre-config-import'); @@ -101,6 +102,9 @@ protected function importConfigSplit($task, $cm_core_key) { $task->drush("pm-enable")->arg('config_split'); $task->drush("config-import")->arg($cm_core_key); } + else { + $this->logger->warning("BLT will NOT import configuration, $core_config_file was not found."); + } } /** From 73209db98e7a0f631ce4d556b9ca63cf7b89a480 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick <matt.grasmick@gmail.com> Date: Mon, 19 Jun 2017 14:29:18 -0400 Subject: [PATCH 4/4] Skipping import and override check if config files are missing. --- src/Robo/Commands/Setup/ConfigCommand.php | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Robo/Commands/Setup/ConfigCommand.php b/src/Robo/Commands/Setup/ConfigCommand.php index 0630f9bf5..562f781fc 100644 --- a/src/Robo/Commands/Setup/ConfigCommand.php +++ b/src/Robo/Commands/Setup/ConfigCommand.php @@ -34,6 +34,17 @@ public function import() { if ($strategy != 'none') { $this->invokeHook('pre-config-import'); + // If using core-only or config-split strategies, first check to see if + // required config is exported. + if (in_array($strategy, ['core-only', 'config-split'])) { + $core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml'; + if (!file_exists($core_config_file)) { + $this->logger->warning("BLT will NOT import configuration, $core_config_file was not found."); + } + // This is not considered a failure. + return 0; + } + $task = $this->taskDrush() ->stopOnFail() ->assume(TRUE) @@ -84,10 +95,7 @@ public function import() { * @param string $cm_core_key */ protected function importCoreOnly($task, $cm_core_key) { - $core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml'; - if (file_exists($core_config_file)) { - $task->drush("config-import")->arg($cm_core_key); - } + $task->drush("config-import")->arg($cm_core_key); } /** @@ -97,14 +105,8 @@ protected function importCoreOnly($task, $cm_core_key) { * @param string $cm_core_key */ protected function importConfigSplit($task, $cm_core_key) { - $core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml'; - if (file_exists($core_config_file)) { - $task->drush("pm-enable")->arg('config_split'); - $task->drush("config-import")->arg($cm_core_key); - } - else { - $this->logger->warning("BLT will NOT import configuration, $core_config_file was not found."); - } + $task->drush("pm-enable")->arg('config_split'); + $task->drush("config-import")->arg($cm_core_key); } /**