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/field/field.module b/core/modules/field/field.module index ad11478..9ab00c4 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -419,18 +419,11 @@ function field_sync_field_status() { $changed = array(); $modules = $module_handler->getModuleList(); foreach ($modules as $module => $module_info) { - // Collect field types and storage backends exposed by the module. - $field_types = (array) $module_handler->invoke($module, 'field_info'); + // Collect storage backends exposed by the module. $storage_types = (array) $module_handler->invoke($module, 'field_storage_info'); - if ($field_types || $storage_types) { + if ($storage_types) { foreach ($fields as $uuid => &$field) { - // Associate field types. - if (isset($field_types[$field['type']]) && ($field['module'] !== $module || !$field['active'])) { - $field['module'] = $module; - $field['active'] = TRUE; - $changed[$uuid] = $field; - } // Associate storage backends. if (isset($storage_types[$field['storage']['type']]) && ($field['storage']['module'] !== $module || !$field['storage']['active'])) { $field['storage']['module'] = $module; @@ -441,12 +434,20 @@ function field_sync_field_status() { } } + $field_types = Drupal::service('plugin.manager.entity.field.field_type')->getDefinitions(); // Set fields with missing field type or storage modules to inactive. foreach ($fields as $uuid => &$field) { + // Associate field types. + if (isset($field_types[$field['type']]) && ($field['module'] != $field_types[$field['type']]['module'] || !$field['active'])) { + $field['module'] = $field_types[$field['type']]['module']; + $field['active'] = TRUE; + $changed[$uuid] = $field; + } if (!isset($modules[$field['module']]) && $field['active']) { $field['active'] = FALSE; $changed[$uuid] = $field; } + // Disassociate storage backends. if (!isset($modules[$field['storage']['module']]) && $field['storage']['active']) { $field['storage']['active'] = FALSE; $changed[$uuid] = $field; diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php index 0fe25e3..a27a53c 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php @@ -34,16 +34,20 @@ public static function getInfo() { */ function testForumUninstallWithField() { // Ensure that the field exists before uninstallation. - $field = field_info_field('taxonomy_forums'); + $field = entity_load('field_entity', 'taxonomy_forums'); $this->assertNotNull($field, 'The taxonomy_forums field exists.'); + $field = entity_load('field_entity', 'comment_node_forum'); + $this->assertNotNull($field, 'The comment_node_forum field exists.'); // Uninstall the forum module which should trigger field deletion. $this->container->get('module_handler')->disable(array('forum')); $this->container->get('module_handler')->uninstall(array('forum')); // Check that the field is now deleted. - $field = field_info_field('taxonomy_forums'); + $field = entity_load('field_entity', 'taxonomy_forums'); $this->assertNull($field, 'The taxonomy_forums field has been deleted.'); + $field = entity_load('field_entity', 'comment_node_forum'); + $this->assertNull($field, 'The comment_node_forum field has been deleted.'); } @@ -51,19 +55,43 @@ 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'); + $field = entity_load('field_entity', 'taxonomy_forums'); $this->assertNotNull($field, 'The taxonomy_forums field exists.'); $field->delete(); // Check that the field is now deleted. - $field = field_info_field('taxonomy_forums'); + $field = entity_load('field_entity', 'taxonomy_forums'); $this->assertNull($field, 'The taxonomy_forums field has been deleted.'); // Ensure that uninstallation succeeds even if the field has already been // deleted manually beforehand. $this->container->get('module_handler')->disable(array('forum')); $this->container->get('module_handler')->uninstall(array('forum')); + + // Ensure comment deleted. + $this->assertFalse(entity_load('comment', $comment->id())); } } 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() {} + }