From 57b145bf9cac4ae599802c0cd0bc68169c1edd37 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Mon, 27 Feb 2017 16:24:12 +0000 Subject: [PATCH] Issue #2855315 by amateescu, hchonov: Remove hard-coding of revision metadata fields in ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck() --- core/lib/Drupal/Core/Entity/ContentEntityBase.php | 13 ++++--------- .../Update/MoveRevisionMetadataFieldsUpdateTest.php | 4 ++-- core/modules/system/system.install | 4 ++++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 6279199fe5fa..70ea52094e46 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -1270,20 +1270,15 @@ public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, * An array of field names. */ protected function getFieldsToSkipFromTranslationChangesCheck() { + /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */ + $entity_type = $this->getEntityType(); // A list of known revision metadata fields which should be skipped from // the comparision. - // @todo Replace the hard coded list of revision metadata fields with the - // solution from https://www.drupal.org/node/2615016. $fields = [ - $this->getEntityType()->getKey('revision'), + $entity_type->getKey('revision'), 'revision_translation_affected', - 'revision_uid', - 'revision_user', - 'revision_timestamp', - 'revision_created', - 'revision_log', - 'revision_log_message', ]; + $fields = array_merge($fields, array_values($entity_type->getRevisionMetadataKeys())); return $fields; } diff --git a/core/modules/system/src/Tests/Entity/Update/MoveRevisionMetadataFieldsUpdateTest.php b/core/modules/system/src/Tests/Entity/Update/MoveRevisionMetadataFieldsUpdateTest.php index 457ced842a03..ba7e028ae09d 100644 --- a/core/modules/system/src/Tests/Entity/Update/MoveRevisionMetadataFieldsUpdateTest.php +++ b/core/modules/system/src/Tests/Entity/Update/MoveRevisionMetadataFieldsUpdateTest.php @@ -26,12 +26,12 @@ public function setDatabaseDumpFiles() { /** * Tests that the revision metadata fields are moved correctly. */ - public function testSystemUpdate3000() { + public function testSystemUpdate8400() { $this->runUpdates(); foreach (['entity_test_revlog', 'entity_test_mul_revlog'] as $entity_type_id) { /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */ - $storage = \Drupal::entityTypeManager()->getStorage($entity_type_id); + $storage = \Drupal::entityTypeManager()->getStorage($entity_type_id); /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */ $entity_type = $storage->getEntityType(); $revision_metadata_field_names = $entity_type->getRevisionMetadataKeys(); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 8f53f91d7716..c4067ef3bbc9 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1834,6 +1834,10 @@ function system_update_8301() { ->save(); } +/** + * @} End of "addtogroup updates-8.3.0". + */ + /** * @addtogroup updates-8.4.x * @{ -- GitLab