Issue #3031727 by quietone, Gábor Hojtsy: Migrate D7 synchronized fields

merge-requests/55/head
Alex Pott 2019-09-09 13:12:00 +01:00
parent 0a3b2beb78
commit b2e2c03327
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
7 changed files with 107 additions and 4 deletions

View File

@ -9,4 +9,5 @@ finished:
entityreference: core
field: field
field_sql_storage: field
i18n_sync: field
number: core

View File

@ -108,6 +108,7 @@ class FieldInstance extends DrupalSqlBase {
->fetch();
$row->setSourceProperty('field_definition', $field_definition);
// Determine the translatable setting.
$translatable = FALSE;
if ($row->getSourceProperty('entity_type') == 'node') {
$language_content_type_bundle = (int) $this->variableGet('language_content_type_' . $row->getSourceProperty('bundle'), 0);
@ -126,6 +127,14 @@ class FieldInstance extends DrupalSqlBase {
$field_data = unserialize($field_definition['data']);
$translatable = $field_data['translatable'];
}
// Check if this is an i18n synchronized field.
$synchronized_fields = $this->variableGet('i18n_sync_node_type_' . $row->getSourceProperty('bundle'), NULL);
if ($synchronized_fields) {
if (in_array($row->getSourceProperty('field_name'), $synchronized_fields)) {
$translatable = FALSE;
}
}
$row->setSourceProperty('translatable', $translatable);
// Get the vid for each allowed value for taxonomy term reference fields

View File

@ -158,6 +158,11 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
];
$this->assertSame($expected_settings, $boolean_field->get('settings'));
// Test a synchronized field is not translatable.
$field = FieldConfig::load('node.article.field_text_plain');
$this->assertInstanceOf(FieldConfig::class, $field);
$this->assertFalse($field->isTranslatable());
// Test the translation settings for taxonomy fields.
$this->assertEntity('node.article.field_vocab_fixed', 'vocab_fixed', 'entity_reference', FALSE, FALSE);
$this->assertEntity('node.article.field_vocab_localize', 'vocab_localize', 'entity_reference', FALSE, FALSE);
@ -174,7 +179,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
// plain text instances should not have been migrated since there's no such
// thing as a string_with_summary field.
$this->assertEntity('node.page.field_text_plain', 'Text plain', 'string', FALSE, FALSE);
$this->assertEntity('node.article.field_text_plain', 'Text plain', 'string', FALSE, TRUE);
$this->assertEntity('node.article.field_text_plain', 'Text plain', 'string', FALSE, FALSE);
$this->assertEntity('node.page.field_text_long_plain', 'Text long plain', 'string_long', FALSE, FALSE);
$this->assertEntity('node.article.field_text_long_plain', 'Text long plain', 'string_long', FALSE, TRUE);
$this->assertNull(FieldConfig::load('node.page.field_text_sum_plain'));

View File

@ -8713,6 +8713,41 @@ $connection->schema()->createTable('field_data_field_text_plain', array(
'mysql_character_set' => 'utf8',
));
$connection->insert('field_data_field_text_plain')
->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'field_text_plain_value',
'field_text_plain_format',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
'entity_id' => '2',
'revision_id' => '2',
'language' => 'und',
'delta' => '0',
'field_text_plain_value' => 'Kai Opaka',
'field_text_plain_format' => NULL,
))
->values(array(
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
'entity_id' => '3',
'revision_id' => '3',
'language' => 'und',
'delta' => '0',
'field_text_plain_value' => 'Kai Opaka',
'field_text_plain_format' => NULL,
))
->execute();
$connection->schema()->createTable('field_data_field_text_plain_filtered', array(
'fields' => array(
'entity_type' => array(
@ -13854,7 +13889,41 @@ $connection->schema()->createTable('field_revision_field_text_plain', array(
),
'mysql_character_set' => 'utf8',
));
$connection->insert('field_revision_field_text_plain')
->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'field_text_plain_value',
'field_text_plain_format',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
'entity_id' => '2',
'revision_id' => '2',
'language' => 'und',
'delta' => '0',
'field_text_plain_value' => 'Kai Opaka',
'field_text_plain_format' => NULL,
))
->values(array(
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
'entity_id' => '3',
'revision_id' => '3',
'language' => 'und',
'delta' => '0',
'field_text_plain_value' => 'Kai Opaka',
'field_text_plain_format' => NULL,
))
->execute();
$connection->schema()->createTable('field_revision_field_text_plain_filtered', array(
'fields' => array(
'entity_type' => array(
@ -52779,7 +52848,7 @@ $connection->insert('system')
'name' => 'i18n_sync',
'type' => 'module',
'owner' => '',
'status' => '0',
'status' => '1',
'bootstrap' => '0',
'schema_version' => '-1',
'weight' => '0',
@ -54817,6 +54886,14 @@ $connection->insert('variable')
'name' => 'i18n_string_textgroup_class_taxonomy',
'value' => 's:29:"i18n_string_textgroup_default";',
))
->values(array(
'name' => 'i18n_sync_node_type_article',
'value' => 'a:1:{i:0;s:16:"field_text_plain";}',
))
->values(array(
'name' => 'i18n_sync_source_article',
'value' => 'i:0;',
))
->values(array(
'name' => 'image_jpeg_quality',
'value' => 'i:80;',

View File

@ -96,6 +96,7 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
'forum',
'help',
'i18n_block',
'i18n_sync',
'image',
'link',
'list',
@ -163,7 +164,6 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
'i18n_redirect',
'i18n_select',
'i18n_string',
'i18n_sync',
'i18n_taxonomy',
'i18n_translation',
'i18n_user',

View File

@ -142,6 +142,7 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
'filter',
'forum',
'i18n_block',
'i18n_sync',
'i18n_variable',
'image',
'link',

View File

@ -210,6 +210,16 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
$node = Node::load(7);
$this->assertEquals(CommentItemInterface::OPEN, $node->comment_forum->status);
// Test synchronized field.
$value = 'Kai Opaka';
$node = Node::load(2);
$this->assertSame($value, $node->field_text_plain->value);
$this->assertArrayNotHasKey('field_text_plain', $node->getTranslatableFields());
$node = $node->getTranslation('is');
$this->assertSame($value, $node->field_text_plain->value);
}
/**