Issue #2961114 by quietone, heddn, Gábor Hojtsy, maxocub, masipila: Migrate D6 i18n CCK field option translations

8.7.x
Gábor Hojtsy 2018-10-25 22:48:13 +02:00
parent 4f89e9a91d
commit a007373c93
14 changed files with 1250 additions and 5 deletions

View File

@ -0,0 +1,178 @@
id: d6_field_instance_option_translation
label: Field instance option configuration translation
migration_tags:
- Drupal 6
- Configuration
- Multilingual
source:
plugin: d6_field_instance_option_translation
skip_count: true
constants:
entity_type: node
property: settings
process:
# We skip field types that don't exist because they weren't migrated by the
# field migration.
field_type_exists:
-
plugin: migration_lookup
migration: d6_field
source:
- objectid
-
plugin: extract
index:
- 1
-
plugin: skip_on_empty
method: row
# Use the process from d6_field to determine the field type.
type:
plugin: field_type
source:
- type
- widget_type
map:
userreference:
userreference_select: entity_reference
userreference_buttons: entity_reference
userreference_autocomplete: entity_reference
nodereference:
nodereference_select: entity_reference
number_integer:
number: integer
optionwidgets_select: list_integer
optionwidgets_buttons: list_integer
optionwidgets_onoff: boolean
number_decimal:
number: decimal
optionwidgets_select: list_float
optionwidgets_buttons: list_float
optionwidgets_onoff: boolean
number_float:
number: float
optionwidgets_select: list_float
optionwidgets_buttons: list_float
optionwidgets_onoff: boolean
email:
email_textfield: email
filefield:
imagefield_widget: image
filefield_widget: file
fr_phone:
phone_textfield: telephone
be_phone:
phone_textfield: telephone
it_phone:
phone_textfield: telephone
el_phone:
phone_textfield: telephone
ch_phone:
phone_textfield: telephone
ca_phone:
phone_textfield: telephone
cr_phone:
phone_textfield: telephone
pa_phone:
phone_textfield: telephone
gb_phone:
phone_textfield: telephone
ru_phone:
phone_textfield: telephone
ua_phone:
phone_textfield: telephone
es_phone:
phone_textfield: telephone
au_phone:
phone_textfield: telephone
cs_phone:
phone_textfield: telephone
hu_phone:
phone_textfield: telephone
pl_phone:
phone_textfield: telephone
nl_phone:
phone_textfield: telephone
se_phone:
phone_textfield: telephone
za_phone:
phone_textfield: telephone
il_phone:
phone_textfield: telephone
nz_phone:
phone_textfield: telephone
br_phone:
phone_textfield: telephone
cl_phone:
phone_textfield: telephone
cn_phone:
phone_textfield: telephone
hk_phone:
phone_textfield: telephone
mo_phone:
phone_textfield: telephone
ph_phone:
phone_textfield: telephone
sg_phone:
phone_textfield: telephone
jo_phone:
phone_textfield: telephone
eg_phone:
phone_textfield: telephone
pk_phone:
phone_textfield: telephone
int_phone:
phone_textfield: telephone
boolean_type:
-
plugin: static_map
source: '@type'
map:
boolean: boolean
default_value: false
-
plugin: skip_on_empty
method: row
bundle:
-
plugin: migration_lookup
migration: d6_node_type
source: type_name
-
plugin: skip_on_empty
method: row
langcode:
plugin: skip_on_empty
source: language
method: row
field_name: objectid
entity_type: 'constants/entity_type'
results:
plugin: d6_field_instance_option_translation
source:
- '@type'
- global_settings
translation:
-
plugin: extract
source: '@results'
index: [1]
-
plugin: skip_on_empty
method: row
property:
-
plugin: extract
source: '@results'
index: [0]
-
plugin: skip_on_empty
method: row
destination:
plugin: entity:field_config
translations: true
migration_dependencies:
required:
- d6_node_type
- d6_field_instance
- d6_field_option_translation

View File

@ -0,0 +1,144 @@
id: d6_field_option_translation
label: Field option configuration translation
migration_tags:
- Drupal 6
- Configuration
- Multilingual
source:
plugin: d6_field_option_translation
skip_count: true
constants:
entity_type: node
allowed_values: settings
process:
entity_type: 'constants/entity_type'
status: active
langcode:
plugin: skip_on_empty
source: language
method: row
field_name: objectid
# Use the process from d6_field to determine the field type.
type:
plugin: field_type
source:
- type
- widget_type
map:
userreference:
userreference_select: entity_reference
userreference_buttons: entity_reference
userreference_autocomplete: entity_reference
nodereference:
nodereference_select: entity_reference
number_integer:
number: integer
optionwidgets_select: list_integer
optionwidgets_buttons: list_integer
optionwidgets_onoff: boolean
number_decimal:
number: decimal
optionwidgets_select: list_float
optionwidgets_buttons: list_float
optionwidgets_onoff: boolean
number_float:
number: float
optionwidgets_select: list_float
optionwidgets_buttons: list_float
optionwidgets_onoff: boolean
email:
email_textfield: email
filefield:
imagefield_widget: image
filefield_widget: file
fr_phone:
phone_textfield: telephone
be_phone:
phone_textfield: telephone
it_phone:
phone_textfield: telephone
el_phone:
phone_textfield: telephone
ch_phone:
phone_textfield: telephone
ca_phone:
phone_textfield: telephone
cr_phone:
phone_textfield: telephone
pa_phone:
phone_textfield: telephone
gb_phone:
phone_textfield: telephone
ru_phone:
phone_textfield: telephone
ua_phone:
phone_textfield: telephone
es_phone:
phone_textfield: telephone
au_phone:
phone_textfield: telephone
cs_phone:
phone_textfield: telephone
hu_phone:
phone_textfield: telephone
pl_phone:
phone_textfield: telephone
nl_phone:
phone_textfield: telephone
se_phone:
phone_textfield: telephone
za_phone:
phone_textfield: telephone
il_phone:
phone_textfield: telephone
nz_phone:
phone_textfield: telephone
br_phone:
phone_textfield: telephone
cl_phone:
phone_textfield: telephone
cn_phone:
phone_textfield: telephone
hk_phone:
phone_textfield: telephone
mo_phone:
phone_textfield: telephone
ph_phone:
phone_textfield: telephone
sg_phone:
phone_textfield: telephone
jo_phone:
phone_textfield: telephone
eg_phone:
phone_textfield: telephone
pk_phone:
phone_textfield: telephone
int_phone:
phone_textfield: telephone
results:
plugin: d6_field_option_translation
source:
- '@type'
- global_settings
translation:
-
plugin: extract
source: '@results'
index: [1]
-
plugin: skip_on_empty
method: row
property:
-
plugin: extract
source: '@results'
index: [0]
-
plugin: skip_on_empty
method: row
destination:
plugin: entity:field_storage_config
translations: true
migration_dependencies:
required:
- d6_field

View File

@ -0,0 +1,53 @@
<?php
namespace Drupal\field\Plugin\migrate\process\d6;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Determines the settings property and translation for boolean fields.
*
* @MigrateProcessPlugin(
* id = "d6_field_instance_option_translation",
* handle_multiples = TRUE
* )
*/
class FieldInstanceOptionTranslation extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($field_type, $global_settings) = $value;
$option_key = 0;
$translation = '';
if (isset($global_settings['allowed_values'])) {
$list = explode("\n", $global_settings['allowed_values']);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
switch ($field_type) {
case 'boolean';
$option = preg_replace('/^option_/', '', $row->getSourceProperty('property'));
for ($i = 0; $i < 2; $i++) {
$value = $list[$i];
$tmp = explode("|", $value);
$original_option_key = isset($tmp[0]) ? $tmp[0] : NULL;
$option_key = ($i === 0) ? 'off_label' : 'on_label';
// Find property with name matching the original option.
if ($option == $original_option_key) {
$translation = $row->getSourceProperty('translation');
break;
}
}
break;
default:
}
}
return ['settings.' . $option_key, $translation];
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace Drupal\field\Plugin\migrate\process\d6;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Determines the allowed values translation for select lists.
*
* @MigrateProcessPlugin(
* id = "d6_field_option_translation",
* handle_multiples = TRUE
* )
*/
class FieldOptionTranslation extends ProcessPluginBase {
/**
* {@inheritdoc}
*
* Get the field default/mapped settings.
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
list($field_type, $global_settings) = $value;
$allowed_values = '';
$i = 0;
if (isset($global_settings['allowed_values'])) {
$list = explode("\n", $global_settings['allowed_values']);
$list = array_map('trim', $list);
$list = array_filter($list, 'strlen');
switch ($field_type) {
case 'list_string':
case 'list_integer':
case 'list_float':
// Remove the prefix used in the i18n_strings table for field options
// to get the option value.
$option = preg_replace('/^option_/', '', $row->getSourceProperty('property'));
$i = 0;
foreach ($list as $allowed_value) {
// Get the key for this allowed value which may be a key|label pair
// or or just key.
$value = explode("|", $allowed_value);
if (isset($value[0]) && ($value[0] == $option)) {
$allowed_values = ['label' => $row->getSourceProperty('translation')];
break;
}
$i++;
}
break;
default:
}
}
return ["settings.allowed_values.$i", $allowed_values];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace Drupal\field\Plugin\migrate\source\d6;
/**
* Gets field instance option label translations.
*
* @MigrateSource(
* id = "d6_field_instance_option_translation",
* source_module = "i18ncck"
* )
*/
class FieldInstanceOptionTranslation extends FieldOptionTranslation {
/**
* {@inheritdoc}
*/
public function query() {
$query = parent::query();
$query->join('content_node_field_instance', 'cnfi', 'cnf.field_name = cnfi.field_name');
$query->addField('cnfi', 'type_name');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
'type_name' => $this->t('Type (article, page, ....)'),
];
return parent::fields() + $fields;
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace Drupal\field\Plugin\migrate\source\d6;
/**
* Gets field option label translations.
*
* @MigrateSource(
* id = "d6_field_option_translation",
* source_module = "i18ncck"
* )
*/
class FieldOptionTranslation extends Field {
/**
* {@inheritdoc}
*/
public function query() {
// Get the fields that have field options translations.
$query = $this->select('i18n_strings', 'i18n')
->fields('i18n')
->fields('lt', [
'translation',
'language',
'plid',
'plural',
'i18n_status',
])
->condition('i18n.type', 'field')
->condition('property', 'option\_%', 'LIKE')
->isNotNull('translation');
$query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
$query->leftjoin('content_node_field', 'cnf', 'cnf.field_name = i18n.objectid');
$query->addField('cnf', 'field_name');
$query->addField('cnf', 'global_settings');
// Minimise changes to the d6_field_option_translation.yml, which is copied
// from d6_field.yml, by ensuring the 'type' property is from
// content_node_field table.
$query->addField('cnf', 'type');
$query->addField('i18n', 'type', 'i18n_type');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
'property' => $this->t('Option ID.'),
'objectid' => $this->t('Object ID'),
'objectindex' => $this->t('Integer value of Object ID'),
'format' => $this->t('The input format used by this string'),
'lid' => $this->t('Source string ID'),
'language' => $this->t('Language code'),
'translation' => $this->t('Translation of the option'),
'plid' => $this->t('Parent lid'),
'plural' => $this->t('Plural index number in case of plural strings'),
];
return parent::fields() + $fields;
}
/**
* {@inheritdoc}
*/
/**
* {@inheritdoc}
*/
public function getIds() {
return parent::getIds() +
[
'language' => ['type' => 'string'],
'property' => ['type' => 'string'],
];
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace Drupal\Tests\field\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Migrate field instance option translations.
*
* @group migrate_drupal_6
*/
class MigrateFieldInstanceOptionTranslationTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules =
[
'config_translation',
'language',
'locale',
'menu_ui',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['node']);
$this->executeMigrations([
'language',
'd6_node_type',
'd6_field',
'd6_field_instance',
'd6_field_option_translation',
'd6_field_instance_option_translation',
]);
}
/**
* Tests migration of file variables to file.settings.yml.
*/
public function testFieldInstanceOptionTranslation() {
$language_manager = $this->container->get('language_manager');
/** @var \Drupal\language\Config\LanguageConfigOverride $config_translation */
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.node.story.field_test_float_single_checkbox');
$option_translation = ['on_label' => 'fr - 1.234'];
$this->assertSame($option_translation, $config_translation->get('settings'));
$config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.field.node.story.field_test_float_single_checkbox');
$option_translation = ['on_label' => 'zu - 1.234'];
$this->assertSame($option_translation, $config_translation->get('settings'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.node.story.field_test_text_single_checkbox');
$option_translation = [
'off_label' => 'fr - Hello',
'on_label' => 'fr - Goodbye',
];
$this->assertSame($option_translation, $config_translation->get('settings'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.node.story.field_test_text_single_checkbox2');
$option_translation = [
'off_label' => 'fr - Off',
'on_label' => 'fr - Hello',
];
$this->assertSame($option_translation, $config_translation->get('settings'));
$config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.field.node.story.field_test_text_single_checkbox2');
$option_translation = ['on_label' => 'zu - Hello'];
$this->assertSame($option_translation, $config_translation->get('settings'));
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace Drupal\Tests\field\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Migrate field option translations.
*
* @group migrate_drupal_6
*/
class MigrateFieldOptionTranslationTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'config_translation',
'language',
'locale',
'menu_ui',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigrations([
'language',
'd6_field',
'd6_field_option_translation',
]);
}
/**
* Tests the Drupal 6 field to Drupal 8 migration.
*/
public function testFieldOptionTranslation() {
$language_manager = $this->container->get('language_manager');
// Test a select list with allowed values of key only.
/** @var \Drupal\language\Config\LanguageConfigOverride $config_translation */
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_test_integer_selectlist');
$allowed_values = [
1 => [
'label' => 'fr - 2341',
],
3 => [
'label' => 'fr - 4123',
],
];
$this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
$config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.storage.node.field_test_integer_selectlist');
$allowed_values = [
1 => [
'label' => 'zu - 2341',
],
];
$this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
// Test a select list with allowed values of key|label.
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.storage.node.field_test_string_selectlist');
$allowed_values = [
0 => [
'label' => 'Noir',
],
];
$this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
$config_translation = $language_manager->getLanguageConfigOverride('zu', 'field.storage.node.field_test_string_selectlist');
$allowed_values = [
0 => [
'label' => 'Okumnyama',
],
1 => [
'label' => 'Mhlophe',
],
];
$this->assertSame($allowed_values, $config_translation->get('settings.allowed_values'));
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
/**
* Tests the field instance option translation source plugin.
*
* @covers \Drupal\field\Plugin\migrate\source\d6\FieldInstanceOptionTranslation
* @group migrate_drupal
*/
class FieldInstanceOptionTranslationTest extends FieldOptionTranslationTest {
/**
* {@inheritdoc}
*/
public static $modules = ['field', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$test = parent::providerSource();
// FieldInstanceOptionTranslation extends FieldOptionTranslation so the
// same test can be used with the addition of the 'type' field to the
// output.
$test[0]['expected_results'][0]['type'] = 'text';
$test[0]['expected_results'][1]['type'] = 'text';
$test[0]['expected_results'][2]['type'] = 'number_integer';
$test[0]['expected_results'][3]['type'] = 'number_integer';
return $test;
}
}

View File

@ -0,0 +1,242 @@
<?php
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the field option translation source plugin.
*
* @covers \Drupal\field\Plugin\migrate\source\d6\FieldOptionTranslation
* @group migrate_drupal
*/
class FieldOptionTranslationTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['field', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$test = [];
// The source data.
$test[0]['source_data']['content_node_field'] = [
[
'field_name' => 'field_test_text_single_checkbox',
'type' => 'text',
'global_settings' => 'a:4:{s:15:"text_processing";s:1:"0";s:10:"max_length";s:0:"";s:14:"allowed_values";s:10:"Off\\nHello";s:18:"allowed_values_php";s:0:"";}',
'required' => 0,
'multiple' => 0,
'db_storage' => 1,
'module' => 'text',
],
[
'field_name' => 'field_test_integer_selectlist',
'type' => 'number_integer',
'global_settings' => 'a:6:{s:6:"prefix";s:0:"";s:6:"suffix";s:0:"";s:3:"min";s:0:"";s:3:"max";s:0:"";s:14:"allowed_values";s:22:"1234\\n2341\\n3412\\n4123";s:18:"allowed_values_php";s:0:"";}',
'required' => 0,
'multiple' => 0,
'db_storage' => 1,
'module' => 'text',
],
];
$test[0]['source_data']['content_node_field_instance'] = [
[
'field_name' => 'field_test_text_single_checkbox',
'type_name' => 'story',
'weight' => 1,
'label' => 'Text Single Checkbox Field',
'widget_type' => 'optionwidgets_onoff',
'description' => 'An example text field using a single on/off checkbox.',
'widget_module' => 'optionwidgets',
'widget_active' => 1,
'required' => 1,
'active' => 1,
'global_settings' => 'a:0;',
'widget_settings' => 'a:0;',
'display_settings' => 'a:0;',
],
[
'field_name' => 'field_test_integer_selectlist',
'type_name' => 'story',
'weight' => 1,
'label' => 'Integer Select List Field',
'widget_type' => 'optionwidgets_select',
'description' => 'An example integer field using a select list.',
'widget_module' => 'optionwidgets',
'widget_active' => 1,
'required' => 1,
'active' => 1,
'global_settings' => 'a:0;',
'widget_settings' => 'a:0;',
'display_settings' => 'a:0;',
],
];
$test[0]['source_data']['i18n_strings'] = [
[
'lid' => 10,
'objectid' => 'field_test_text_single_checkbox',
'type' => 'field',
'property' => 'option_0',
'objectindex' => 0,
'format' => 0,
],
[
'lid' => 11,
'objectid' => 'field_test_text_single_checkbox',
'type' => 'field',
'property' => 'option_1',
'objectindex' => 0,
'format' => 0,
],
[
'lid' => 20,
'objectid' => 'field_test_integer_selectlist',
'type' => 'field',
'property' => 'option_1234',
'objectindex' => 0,
'format' => 0,
],
[
'lid' => 21,
'objectid' => 'field_test_integer_selectlist',
'type' => 'field',
'property' => 'option_4123',
'objectindex' => 0,
'format' => 0,
],
];
$test[0]['source_data']['locales_target'] = [
[
'lid' => 10,
'translation' => "fr - Hello",
'language' => 'fr',
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'lid' => 11,
'translation' => 'fr - Goodbye',
'language' => 'fr',
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'lid' => 20,
'translation' => "fr - 4444",
'language' => 'fr',
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'lid' => 21,
'translation' => 'fr - 5555',
'language' => 'fr',
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
];
$test[0]['expected_results'] = [
[
'field_name' => 'field_test_text_single_checkbox',
'type' => 'text',
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => 'Off\nHello',
'allowed_values_php' => '',
'max_length' => '',
'text_processing' => '0',
],
'db_columns' => '',
'property' => 'option_0',
'objectid' => 'field_test_text_single_checkbox',
'language' => 'fr',
'translation' => 'fr - Hello',
'objectindex' => 0,
'format' => 0,
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'field_name' => 'field_test_text_single_checkbox',
'type' => 'text',
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => 'Off\nHello',
'allowed_values_php' => '',
'max_length' => '',
'text_processing' => '0',
],
'db_columns' => '',
'property' => 'option_1',
'objectid' => 'field_test_text_single_checkbox',
'language' => 'fr',
'translation' => 'fr - Goodbye',
'objectindex' => 0,
'format' => 0,
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'field_name' => 'field_test_integer_selectlist',
'type' => 'number_integer',
'widget_type' => 'optionwidgets_select',
'global_settings' => [
'allowed_values' => '1234\n2341\n3412\n4123',
'max' => '',
'min' => '',
'prefix' => '',
'suffix' => '',
'allowed_values_php' => '',
],
'db_columns' => '',
'property' => 'option_1234',
'objectid' => 'field_test_integer_selectlist',
'language' => 'fr',
'translation' => 'fr - 4444',
'objectindex' => 0,
'format' => 0,
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
[
'field_name' => 'field_test_integer_selectlist',
'type' => 'number_integer',
'widget_type' => 'optionwidgets_select',
'global_settings' => [
'allowed_values' => '1234\n2341\n3412\n4123',
'max' => '',
'min' => '',
'prefix' => '',
'suffix' => '',
'allowed_values_php' => '',
],
'db_columns' => '',
'property' => 'option_4123',
'objectid' => 'field_test_integer_selectlist',
'language' => 'fr',
'translation' => 'fr - 5555',
'objectindex' => 0,
'format' => 0,
'plid' => 0,
'plural' => 0,
'i18n_status' => 0,
],
];
return $test;
}
}

View File

@ -268,7 +268,7 @@ class EntityConfigBase extends Entity {
// The entity id does not include the langcode.
$id_values = [];
foreach ($destination_identifier as $key => $value) {
if ($this->isTranslationDestination() && $key == 'langcode') {
if ($this->isTranslationDestination() && $key === 'langcode') {
continue;
}
$id_values[] = $value;

View File

@ -58,6 +58,10 @@ class EntityFieldStorageConfig extends EntityConfigBase {
public function getIds() {
$ids['entity_type']['type'] = 'string';
$ids['field_name']['type'] = 'string';
// @todo: Remove conditional. https://www.drupal.org/node/3004574
if ($this->isTranslationDestination()) {
$ids['langcode']['type'] = 'string';
}
return $ids;
}
@ -65,8 +69,18 @@ class EntityFieldStorageConfig extends EntityConfigBase {
* {@inheritdoc}
*/
public function rollback(array $destination_identifier) {
$destination_identifier = implode('.', $destination_identifier);
parent::rollback([$destination_identifier]);
if ($this->isTranslationDestination()) {
$language = $destination_identifier['langcode'];
unset($destination_identifier['langcode']);
$destination_identifier = [
implode('.', $destination_identifier),
'langcode' => $language,
];
}
else {
$destination_identifier = [implode('.', $destination_identifier)];
}
parent::rollback($destination_identifier);
}
}

View File

@ -3012,6 +3012,18 @@ $connection->insert('content_node_field')
'active' => '1',
'locked' => '0',
))
->values(array(
'field_name' => 'field_test_string_selectlist',
'type' => 'text',
'global_settings' => "a:4:{s:15:\"text_processing\";s:1:\"0\";s:10:\"max_length\";s:0:\"\";s:14:\"allowed_values\";s:18:\"A|Black\r\nB|White\r\n\";s:18:\"allowed_values_php\";s:0:\"\";}",
'required' => '0',
'multiple' => '0',
'db_storage' => '1',
'module' => 'text',
'db_columns' => 'a:1:{s:5:"value";a:5:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;s:8:"sortable";b:1;s:5:"views";b:1;}}',
'active' => '1',
'locked' => '0',
))
->values(array(
'field_name' => 'field_test_text_single_checkbox',
'type' => 'text',
@ -3430,6 +3442,18 @@ $connection->insert('content_node_field_instance')
'widget_module' => 'phone',
'widget_active' => '1',
))
->values(array(
'field_name' => 'field_test_string_selectlist',
'type_name' => 'story',
'weight' => '31',
'label' => 'String Select List Field',
'widget_type' => 'optionwidgets_select',
'widget_settings' => 'a:2:{s:13:"default_value";a:1:{i:0;a:1:{s:5:"value";s:0:"";}}s:17:"default_value_php";N;}',
'display_settings' => 'a:5:{s:5:"label";a:2:{s:6:"format";s:5:"above";s:7:"exclude";i:0;}i:5;a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}s:6:"teaser";a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}s:4:"full";a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}i:4;a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}}',
'description' => '',
'widget_module' => 'optionwidgets',
'widget_active' => '1',
))
->values(array(
'field_name' => 'field_test_text_single_checkbox',
'type_name' => 'story',
@ -3822,6 +3846,11 @@ $connection->schema()->createTable('content_type_story', array(
'not null' => FALSE,
'length' => '100',
),
'field_test_string_selectlist_value' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
),
),
'primary key' => array(
'vid',
@ -3865,6 +3894,7 @@ $connection->insert('content_type_story')
'field_test_text_single_checkbox2_value',
'field_test_datestamp_value2',
'field_test_datetime_value2',
'field_test_string_selectlist_value',
))
->values(array(
'nid' => '1',
@ -3896,6 +3926,7 @@ $connection->insert('content_type_story')
'field_test_text_single_checkbox2_value' => 'Hello',
'field_test_datestamp_value2' => NULL,
'field_test_datetime_value2' => NULL,
'field_test_string_selectlist_value' => NULL,
))
->values(array(
'nid' => '1',
@ -3927,6 +3958,7 @@ $connection->insert('content_type_story')
'field_test_text_single_checkbox2_value' => NULL,
'field_test_datestamp_value2' => NULL,
'field_test_datetime_value2' => NULL,
'field_test_string_selectlist_value' => NULL,
))
->values(array(
'nid' => '2',
@ -3958,6 +3990,7 @@ $connection->insert('content_type_story')
'field_test_text_single_checkbox2_value' => NULL,
'field_test_datestamp_value2' => NULL,
'field_test_datetime_value2' => NULL,
'field_test_string_selectlist_value' => NULL,
))
->values(array(
'nid' => '2',
@ -3989,6 +4022,7 @@ $connection->insert('content_type_story')
'field_test_text_single_checkbox2_value' => NULL,
'field_test_datestamp_value2' => NULL,
'field_test_datetime_value2' => NULL,
'field_test_string_selectlist_value' => NULL,
))
->values(array(
'nid' => '9',
@ -4020,6 +4054,7 @@ $connection->insert('content_type_story')
'field_test_text_single_checkbox2_value' => 'Off',
'field_test_datestamp_value2' => '1391357160',
'field_test_datetime_value2' => '2015-03-04 06:07:00',
'field_test_string_selectlist_value' => NULL,
))
->execute();
@ -9956,6 +9991,86 @@ $connection->insert('i18n_strings')
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1680',
'objectid' => 'employee-field_company',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1681',
'objectid' => 'employee-field_commander',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1682',
'objectid' => 'employee-field_company_2',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1683',
'objectid' => 'employee-field_company_3',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1684',
'objectid' => 'page-field_reference',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1685',
'objectid' => 'page-field_reference_2',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1686',
'objectid' => 'story-field_test_string_selectlist',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1689',
'objectid' => 'test_planet-field_test_text_single_checkbox',
'type' => 'field',
'property' => 'widget_label',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1690',
'objectid' => 'field_test_string_selectlist',
'type' => 'field',
'property' => 'option_A',
'objectindex' => '0',
'format' => '0',
))
->values(array(
'lid' => '1691',
'objectid' => 'field_test_string_selectlist',
'type' => 'field',
'property' => 'option_B',
'objectindex' => '0',
'format' => '0',
))
->execute();
$connection->schema()->createTable('i18n_variable', array(
@ -22457,6 +22572,76 @@ $connection->insert('locales_source')
'source' => 'Translation test',
'version' => '1',
))
->values(array(
'lid' => '1680',
'location' => 'field:employee-field_company:widget_label',
'textgroup' => 'cck',
'source' => 'Company',
'version' => '1',
))
->values(array(
'lid' => '1681',
'location' => 'field:employee-field_commander:widget_label',
'textgroup' => 'cck',
'source' => 'Commanding Officer',
'version' => '1',
))
->values(array(
'lid' => '1682',
'location' => 'field:employee-field_company_2:widget_label',
'textgroup' => 'cck',
'source' => 'Company 2',
'version' => '1',
))
->values(array(
'lid' => '1683',
'location' => 'field:employee-field_company_3:widget_label',
'textgroup' => 'cck',
'source' => 'Company 3',
'version' => '1',
))
->values(array(
'lid' => '1684',
'location' => 'field:page-field_reference:widget_label',
'textgroup' => 'cck',
'source' => 'Reference',
'version' => '1',
))
->values(array(
'lid' => '1685',
'location' => 'field:page-field_reference_2:widget_label',
'textgroup' => 'cck',
'source' => 'Reference',
'version' => '1',
))
->values(array(
'lid' => '1686',
'location' => 'field:story-field_test_string_selectlist:widget_label',
'textgroup' => 'cck',
'source' => 'String Select List Field',
'version' => '1',
))
->values(array(
'lid' => '1689',
'location' => 'field:test_planet-field_test_text_single_checkbox:widget_label',
'textgroup' => 'cck',
'source' => 'Text Single Checkbox Field',
'version' => '1',
))
->values(array(
'lid' => '1690',
'location' => 'field:field_test_string_selectlist:option_A',
'textgroup' => 'cck',
'source' => 'Black',
'version' => '1',
))
->values(array(
'lid' => '1691',
'location' => 'field:field_test_string_selectlist:option_B',
'textgroup' => 'cck',
'source' => 'White',
'version' => '1',
))
->execute();
$connection->schema()->createTable('locales_target', array(
@ -27293,6 +27478,14 @@ $connection->insert('locales_target')
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '607',
'translation' => 'fr - 1.234',
'language' => 'fr',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '608',
'translation' => 'fr - Integer Select List Field',
@ -27309,6 +27502,22 @@ $connection->insert('locales_target')
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '611',
'translation' => 'fr - 2341',
'language' => 'fr',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '613',
'translation' => 'fr - 4123',
'language' => 'fr',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '614',
'translation' => 'fr - Text Single Checkbox Field',
@ -27501,6 +27710,14 @@ $connection->insert('locales_target')
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '1690',
'translation' => 'Noir',
'language' => 'fr',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '66',
'translation' => 'zu - CCK - Aucune Intégration aux Vues',
@ -27581,6 +27798,22 @@ $connection->insert('locales_target')
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '607',
'translation' => 'zu - 1.234',
'language' => 'zu',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '611',
'translation' => 'zu - 2341',
'language' => 'zu',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '621',
'translation' => 'zu - Hello',
@ -27597,6 +27830,22 @@ $connection->insert('locales_target')
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '1690',
'translation' => 'Okumnyama',
'language' => 'zu',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->values(array(
'lid' => '1691',
'translation' => 'Mhlophe',
'language' => 'zu',
'plid' => '0',
'plural' => '0',
'i18n_status' => '0',
))
->execute();
$connection->schema()->createTable('menu_custom', array(

View File

@ -67,8 +67,8 @@ class MigrateUpgrade6Test extends MigrateUpgradeExecuteTestBase {
'contact_form' => 5,
'configurable_language' => 5,
'editor' => 2,
'field_config' => 89,
'field_storage_config' => 63,
'field_config' => 90,
'field_storage_config' => 64,
'file' => 7,
'filter_format' => 7,
'image_style' => 5,