Commit 35161851 authored by catch's avatar catch
Browse files

Issue #2925550 by Berdir, amateescu: Fields with a manually defined initial...

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
parent 892c0f3c
......@@ -228,8 +228,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;
}
/**
......
<?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();
<?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();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment