diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index d180381345..9797e7bb73 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -204,8 +204,10 @@ public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterfac $current_schema = $this->getSchemaFromStorageDefinition($storage_definition); $this->processFieldStorageSchema($current_schema); + $installed_schema = $this->loadFieldSchemaData($original); + $this->processFieldStorageSchema($installed_schema); - return $current_schema != $this->loadFieldSchemaData($original); + return $current_schema != $installed_schema; } /** diff --git a/core/modules/system/tests/fixtures/update/drupal-8.entity-test-initial.php b/core/modules/system/tests/fixtures/update/drupal-8.entity-test-initial.php new file mode 100644 index 0000000000..e7ab6961e6 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.entity-test-initial.php @@ -0,0 +1,24 @@ +select('key_value') + ->fields('key_value', ['value']) + ->condition('collection', 'entity.storage_schema.sql') + ->condition('name', 'entity_test_update.field_schema_data.name') + ->execute() + ->fetchField(); + +$schema = unserialize($schema); +$schema['entity_test_update']['fields']['name']['initial'] = 'test'; + +$connection->update('key_value') + ->fields(['value' => serialize($schema)]) + ->condition('collection', 'entity.storage_schema.sql') + ->condition('name', 'entity_test_update.field_schema_data.name') + ->execute(); diff --git a/core/modules/system/tests/src/Functional/Update/EntityUpdateInitialTest.php b/core/modules/system/tests/src/Functional/Update/EntityUpdateInitialTest.php new file mode 100644 index 0000000000..d4d79f96b5 --- /dev/null +++ b/core/modules/system/tests/src/Functional/Update/EntityUpdateInitialTest.php @@ -0,0 +1,33 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update.php.gz', + __DIR__ . '/../../../fixtures/update/drupal-8.entity-test-initial.php', + ]; + } + + /** + * Tests that a pre-existing initial key in the field schema is not a change. + */ + public function testInitialIsIgnored() { + $this->runUpdates(); + } + +}