summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-04-11 11:19:54 (GMT)
committerAlex Pott2018-04-11 11:19:54 (GMT)
commit7e11010140974da99aaa5b731bff5312b67d6357 (patch)
tree9e753d6f51412815b2b5a59729346e3e9d6159e5
parent4e43216ffeb335e750489b9f5f8559d5e188086d (diff)
Issue #2960054 by Sam152: content_moderation_post_update_update_cms_default_revisions fails if content_moderation was enabled but no entity types were being moderated
-rw-r--r--core/modules/content_moderation/content_moderation.post_update.php1
-rw-r--r--core/modules/content_moderation/tests/src/Functional/DefaultContentModerationStateRevisionUpdateTest.php14
2 files changed, 14 insertions, 1 deletions
diff --git a/core/modules/content_moderation/content_moderation.post_update.php b/core/modules/content_moderation/content_moderation.post_update.php
index e2e583e..ff5a28a 100644
--- a/core/modules/content_moderation/content_moderation.post_update.php
+++ b/core/modules/content_moderation/content_moderation.post_update.php
@@ -20,6 +20,7 @@ function content_moderation_post_update_update_cms_default_revisions(&$sandbox)
$entity_type_id = &$sandbox['entity_type_id'];
if (!isset($entity_type_id)) {
$sandbox['bundles'] = [];
+ $sandbox['entity_type_ids'] = [];
/** @var \Drupal\workflows\WorkflowInterface $workflow */
foreach (Workflow::loadMultipleByType('content_moderation') as $workflow) {
/** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration $plugin */
diff --git a/core/modules/content_moderation/tests/src/Functional/DefaultContentModerationStateRevisionUpdateTest.php b/core/modules/content_moderation/tests/src/Functional/DefaultContentModerationStateRevisionUpdateTest.php
index 6ec6b05..4d5314d 100644
--- a/core/modules/content_moderation/tests/src/Functional/DefaultContentModerationStateRevisionUpdateTest.php
+++ b/core/modules/content_moderation/tests/src/Functional/DefaultContentModerationStateRevisionUpdateTest.php
@@ -20,7 +20,6 @@ class DefaultContentModerationStateRevisionUpdateTest extends UpdatePathTestBase
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz',
__DIR__ . '/../../fixtures/update/drupal-8.4.0-content_moderation_installed.php',
- __DIR__ . '/../../fixtures/update/drupal-8.default-cms-entity-id-2941736.php',
];
}
@@ -28,6 +27,11 @@ class DefaultContentModerationStateRevisionUpdateTest extends UpdatePathTestBase
* Test updating the default revision.
*/
public function testUpdateDefaultRevision() {
+ // Include the database fixture required to test updating the default
+ // revision. This is excluded from ::setDatabaseDumpFiles so that we can
+ // test the same post_update hook with no test content enabled.
+ require __DIR__ . '/../../fixtures/update/drupal-8.default-cms-entity-id-2941736.php';
+
$this->runUpdates();
foreach (['node', 'block_content'] as $entity_type_id) {
@@ -46,6 +50,14 @@ class DefaultContentModerationStateRevisionUpdateTest extends UpdatePathTestBase
}
/**
+ * Test the post_update hook when no entity types are being moderated.
+ */
+ public function testNoEntitiesUnderModeration() {
+ // If any errors occur during the post_update hook, the test case will fail.
+ $this->runUpdates();
+ }
+
+ /**
* Assert for the given entity, the default revision ID matches.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity