diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php index a0cb95d..017f3fb 100644 --- a/core/modules/comment/src/Tests/CommentFieldsTest.php +++ b/core/modules/comment/src/Tests/CommentFieldsTest.php @@ -63,6 +63,29 @@ function testCommentDefaultFields() { } /** + * Tests that you can remove a comment field. + */ + public function testCommentFieldDelete() { + $this->drupalCreateContentType(array('type' => 'test_node_type')); + $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type'); + // We want to test the handling of removing the primary comment field, so we + // ensure there is at least one other comment field attached to a node type + // so that comment_entity_load() runs for nodes. + $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'comment2'); + + // Create a sample node. + $node = $this->drupalCreateNode(array( + 'title' => 'Baloney', + 'type' => 'test_node_type', + )); + + // Delete the first comment field. + FieldStorageConfig::loadByName('node', 'comment')->delete(); + $this->drupalGet('node/' . $node->nid->value); + $this->assertResponse(200); + } + + /** * Tests that comment module works when installed after a content module. */ function testCommentInstallAfterContentModule() { diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index c117e61..4c14535 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -742,6 +742,7 @@ function forum_system_info_alter(&$info, Extension $file, $type) { ->condition('type', 'forum') ->count() ->accessCheck(FALSE) + ->range(0, 1) ->execute(); if (!empty($nodes)) { $info['required'] = TRUE; @@ -752,6 +753,7 @@ function forum_system_info_alter(&$info, Extension $file, $type) { ->condition('vid', $vid) ->count() ->accessCheck(FALSE) + ->range(0, 1) ->execute(); if (!empty($terms)) { $vocabulary = Vocabulary::load($vid); @@ -770,15 +772,10 @@ function forum_system_info_alter(&$info, Extension $file, $type) { } } else { - if ($vocabulary->access('view')) { - $info['explanation'] = t('To uninstall Forum first delete all %vocabulary terms.', [ - '%vocabulary' => $vocabulary->label(), - '!url' => $vocabulary->url('overview-form'), - ]); - } - else { - $info['explanation'] = t('To uninstall Forum first delete all %vocabulary terms.', ['%vocabulary' => $vocabulary->label()]); - } + $info['explanation'] = t('To uninstall Forum first delete all %vocabulary terms.', [ + '%vocabulary' => $vocabulary->label(), + '!url' => $vocabulary->url('overview-form'), + ]); } } }