summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2017-03-26 01:05:33 (GMT)
committerAlex Pott2017-03-26 01:05:33 (GMT)
commitacc5c66d7f7effb29e2781eaa2eeef30a0c92cb5 (patch)
treefc84808f46ebaeb88fc528b27e1ad40f233be9c4
parent2b98f31fe6eb4be98101400daf15142521a7f674 (diff)
Issue #2498291 by Jo Fitzgerald, neclimdul, quietone, KarenS, mikeryan, mitrpaka, phenaproxima: Fields hidden in some view modes abort migration (D6)
-rw-r--r--core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php5
-rw-r--r--core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php16
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal6.php2
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php5
4 files changed, 25 insertions, 3 deletions
diff --git a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php
index 43d2782..33852d6 100644
--- a/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php
+++ b/core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php
@@ -28,7 +28,10 @@ class FieldInstancePerViewMode extends ViewModeBase {
$field_name = $field_row['field_name'];
foreach ($this->getViewModes() as $view_mode) {
- if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
+ // Append to the return value if the row has display settings for this
+ // view mode and the view mode is neither hidden nor excluded.
+ // @see \Drupal\node\Plugin\migrate\source\d6\ViewMode::initializeIterator()
+ if (isset($field_row['display_settings'][$view_mode]) && $field_row['display_settings'][$view_mode]['format'] != 'hidden' && empty($field_row['display_settings'][$view_mode]['exclude'])) {
$index = $view_mode . "." . $bundle . "." . $field_name;
$rows[$index]['entity_type'] = 'node';
$rows[$index]['view_mode'] = $view_mode;
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php
index 9775c5b..fc81c49 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php
@@ -21,6 +21,19 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
}
/**
+ * Asserts that a particular component is NOT included in a display.
+ *
+ * @param string $display_id
+ * The display ID.
+ * @param string $component_id
+ * The component ID.
+ */
+ protected function assertComponentNotExists($display_id, $component_id) {
+ $component = EntityViewDisplay::load($display_id)->getComponent($component_id);
+ $this->assertNull($component);
+ }
+
+ /**
* Test that migrated entity display settings can be loaded using D8 API's.
*/
public function testEntityDisplaySettings() {
@@ -177,6 +190,9 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
$this->assertIdentical($expected, $component);
// Test that our Id map has the correct data.
$this->assertIdentical(['node', 'story', 'teaser', 'field_test'], $this->getMigration('d6_field_formatter_settings')->getIdMap()->lookupDestinationID(['story', 'teaser', 'node', 'field_test']));
+
+ // Test hidden field.
+ $this->assertComponentNotExists('node.test_planet.teaser', 'field_test_text_single_checkbox');
}
}
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
index 1092c11..71bccd4 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php
@@ -3018,7 +3018,7 @@ $connection->insert('content_node_field_instance')
'label' => 'Text Single Checkbox Field',
'widget_type' => 'text_textfield',
'widget_settings' => 'a:4:{s:13:"default_value";a:1:{i:0;a:2:{s:5:"value";s:1:"0";s:14:"_error_element";s:63:"default_value_widget][field_test_text_single_checkbox][0][value";}}s:17:"default_value_php";N;s:4:"rows";i:5;s:4:"size";s:3:"255";}',
- 'display_settings' => 'a:7:{s:6:"weight";s:2:"17";s:6:"parent";s:0:"";i:5;a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}s:5:"label";a:1:{s:6:"format";s:5:"above";}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;}}',
+ 'display_settings' => 'a:7:{s:6:"weight";s:2:"32";s:6:"parent";s:0:"";s:5:"label";a:1:{s:6:"format";s:5:"above";}s:6:"teaser";a:2:{s:6:"format";s:6:"hidden";s:7:"exclude";i:0;}s:4:"full";a:2:{s:6:"format";s:7:"default";s:7:"exclude";i:0;}i:5;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' => 'An example text field using a single on/off checkbox.',
'widget_module' => 'text',
'widget_active' => '1',
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php b/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
index 8e7b8ae..b5a6d4d 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
@@ -21,7 +21,10 @@ class ViewMode extends ViewModeBase {
while ($field_row = $result->fetchAssoc()) {
$field_row['display_settings'] = unserialize($field_row['display_settings']);
foreach ($this->getViewModes() as $view_mode) {
- if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
+ // Append to the return value if the row has display settings for this
+ // view mode and the view mode is neither hidden nor excluded.
+ // @see \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
+ if (isset($field_row['display_settings'][$view_mode]) && $field_row['display_settings'][$view_mode]['format'] != 'hidden' && empty($field_row['display_settings'][$view_mode]['exclude'])) {
if (!isset($rows[$view_mode])) {
$rows[$view_mode]['entity_type'] = 'node';
$rows[$view_mode]['view_mode'] = $view_mode;