diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php index 6f9ad12..ada64a7 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php @@ -160,4 +160,9 @@ public function isEmpty() { return FALSE; } + /** + * {@inheritdoc} + */ + public function prepareCache() {} + } diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php index 0fe25e3..0b76194 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php @@ -36,6 +36,8 @@ function testForumUninstallWithField() { // Ensure that the field exists before uninstallation. $field = field_info_field('taxonomy_forums'); $this->assertNotNull($field, 'The taxonomy_forums field exists.'); + $field = entity_load('field_entity', 'comment_node_forum'); + $this->assertTrue($field->active, 'The comment_node_forum field exists and active.'); // Uninstall the forum module which should trigger field deletion. $this->container->get('module_handler')->disable(array('forum')); @@ -51,6 +53,27 @@ function testForumUninstallWithField() { * Tests if uninstallation succeeds if the field has been deleted beforehand. */ function testForumUninstallWithoutField() { + // Create a post in the forum topic with a comment. + $topic = entity_create('taxonomy_term', array( + 'vid' => 'forums', + 'name' => 'test topic', + )); + $topic->save(); + $post = entity_create('node', array( + 'type' => 'forum', + 'title' => 'test post', + 'taxonomy_forums' => $topic->id(), + 'uid' => 0, + )); + $post->save(); + $comment = entity_create('comment', array( + 'entity_type' => 'node', + 'entity_id' => $post->id(), + 'field_name' => 'comment_node_forum', + 'uid' => 0, + )); + $comment->save(); + // Manually delete the taxonomy_forums field before module uninstallation. $field = field_info_field('taxonomy_forums'); $this->assertNotNull($field, 'The taxonomy_forums field exists.'); @@ -64,6 +87,10 @@ function testForumUninstallWithoutField() { // deleted manually beforehand. $this->container->get('module_handler')->disable(array('forum')); $this->container->get('module_handler')->uninstall(array('forum')); + + // Ensure comment is preserved. + $comment = entity_load('comment', $comment->id()); + $this->assertNotNull($comment, 'Comment is not deleted'); } } diff --git a/core/modules/system/tests/upgrade/drupal-7.all-disabled.database.php b/core/modules/system/tests/upgrade/drupal-7.all-disabled.database.php index b73db60..75ce0b9 100644 --- a/core/modules/system/tests/upgrade/drupal-7.all-disabled.database.php +++ b/core/modules/system/tests/upgrade/drupal-7.all-disabled.database.php @@ -26,3 +26,12 @@ ->condition('type', 'module') ->condition('name', 'update_test_1') ->execute(); + +// @todo Remove this after https://drupal.org/node/2032369 +db_update('system') + ->fields(array( + 'status' => 1, + )) + ->condition('type', 'module') + ->condition('name', 'comment') + ->execute(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php index 21c210b..d0594d3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php @@ -31,4 +31,9 @@ public function getPropertyDefinitions() { return parent::getPropertyDefinitions(); } + /** + * {@inheritdoc} + */ + public function prepareCache() {} + }