diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install
index cf4a3e88f9..f179c5db6e 100644
--- a/core/modules/comment/comment.install
+++ b/core/modules/comment/comment.install
@@ -16,19 +16,24 @@
*/
function comment_requirements($phase) {
$requirements = [];
- if ($phase === 'update') {
+ if ($phase === 'update' && drupal_get_installed_schema_version('comment') < 8701) {
$has_empty_columns = \Drupal::entityQuery('comment', 'OR')
->condition('entity_type', NULL, 'IS NULL')
->condition('field_name', NULL, 'IS NULL')
->range(0, 1)
->accessCheck(FALSE)
- ->count()
->execute();
- $requirements['comment_update_8701'] = [
- 'title' => t('Comment required fields update'),
- 'description' => t('The comment 8701 update requires that the entity_type and field_name fields have values for all comment entities. See the relevant the change record for more information.'),
- 'severity' => $has_empty_columns ? REQUIREMENT_ERROR : REQUIREMENT_OK,
- ];
+ if ($has_empty_columns) {
+ $requirements['comment_update_8701'] = [
+ 'title' => t('Comment required fields update'),
+ 'description' => t('The comment 8701 update requires that the %field_1 and %field_2 fields have values for all comment entities. See the relevant the change record for more information.', [
+ '%field_1' => 'entity_type',
+ '%field_2' => 'field_name',
+ ':change_record' => 'https://www.drupal.org/node/3053046',
+ ]),
+ 'severity' => REQUIREMENT_ERROR,
+ ];
+ }
}
return $requirements;
}
diff --git a/core/modules/comment/tests/src/Functional/Update/CommentUpdateTest.php b/core/modules/comment/tests/src/Functional/Update/CommentUpdateTest.php
index 53a34b896a..f5a7ccfa35 100644
--- a/core/modules/comment/tests/src/Functional/Update/CommentUpdateTest.php
+++ b/core/modules/comment/tests/src/Functional/Update/CommentUpdateTest.php
@@ -129,7 +129,7 @@ public function testCommentEntityTypeAndFieldUpdateRequirementsCheck() {
$this->prepareRunUpdates();
$this->drupalGet($this->updateUrl);
$this->assertSession()->pageTextContains('Errors found');
- $this->assertSession()->elementContains('css', '.system-status-report__entry--error', 'The comment 8701 update requires that the entity_type and field_name fields have values for all comment entities.');
+ $this->assertSession()->elementContains('css', '.system-status-report__entry--error', 'The comment 8701 update requires that the entity_type and field_name fields have values for all comment entities.');
}
}