Issue #2925550 by Berdir, amateescu: Fields with a manually defined initial value in the schema have an Entity schema definition mismatch after updating to Drupal 8.4

8.5.x
Nathaniel Catchpole 2017-11-27 16:36:35 +00:00
parent 892c0f3c4e
commit 3516185109
3 changed files with 60 additions and 1 deletions

View File

@ -228,8 +228,10 @@ class SqlContentEntityStorageSchema implements DynamicallyFieldableEntityStorage
$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;
}
/**

View File

@ -0,0 +1,24 @@
<?php
// @codingStandardsIgnoreFile
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Simulate an entity type that had previously set an initial key schema for a
// field.
$schema = $connection->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();

View File

@ -0,0 +1,33 @@
<?php
namespace Drupal\Tests\system\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
/**
* Tests handling of existing initial keys during updates.
*
* @see https://www.drupal.org/project/drupal/issues/2925550
*
* @group Update
*/
class EntityUpdateInitialTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->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();
}
}