summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Rowlands2017-08-07 08:14:46 (GMT)
committerLee Rowlands2017-08-07 08:14:46 (GMT)
commit2534957ae1caf1275dca747b9fb8cb6f1b2a14ca (patch)
treea95ef61cb127a249e6a1d7ac4f19d7e2fadf5214
parent1da4fed2b9885e9f78dc73c235e8ebe73c84296d (diff)
Issue #2900019 by tim.plunkett, joelpittet: \Drupal\content_moderation\EventSubscriber\ConfigImportSubscriber causes errors when importing any non-workflow config
-rw-r--r--core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php9
-rw-r--r--core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php15
2 files changed, 20 insertions, 4 deletions
diff --git a/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php b/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php
index a0598fa..930167f 100644
--- a/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php
+++ b/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php
@@ -81,15 +81,18 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
* @param string $config_name
* The configuration object name.
*
- * @return \Drupal\Core\Entity\EntityInterface|null
- * An entity object. NULL if no matching entity is found.
+ * @return \Drupal\workflows\WorkflowInterface|null
+ * A workflow entity object. NULL if no matching entity is found.
*/
protected function getWorkflow($config_name) {
$entity_type_id = $this->configManager->getEntityTypeIdByName($config_name);
+ if ($entity_type_id !== 'workflow') {
+ return;
+ }
+
/** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$entity_id = ConfigEntityStorage::getIDFromConfigName($config_name, $entity_type->getConfigPrefix());
- /** @var \Drupal\workflows\WorkflowInterface $workflow */
return $this->entityTypeManager->getStorage($entity_type_id)->load($entity_id);
}
diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php
index 7e2d972..931056e 100644
--- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php
+++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php
@@ -79,9 +79,22 @@ class ContentModerationWorkflowConfigTest extends KernelTestBase {
* Test deleting a state via config import.
*/
public function testDeletingStateViaConfiguration() {
+ $config_sync = \Drupal::service('config.storage.sync');
+
+ // Alter the workflow data.
$config_data = $this->config('workflows.workflow.editorial')->get();
unset($config_data['type_settings']['states']['test1']);
- \Drupal::service('config.storage.sync')->write('workflows.workflow.editorial', $config_data);
+ $config_sync->write('workflows.workflow.editorial', $config_data);
+
+ // Alter the data of another entity type.
+ $config_data = $this->config('node.type.example')->get();
+ $config_data['description'] = 'A new description';
+ $config_sync->write('node.type.example', $config_data);
+
+ // Alter the values of simple config.
+ $config_data = $this->config('core.extension')->get();
+ $config_data['module']['node'] = 1;
+ $config_sync->write('core.extension', $config_data);
// There are no Nodes with the moderation state test1, so this should run
// with no errors.