From 392522c083c860f3c28a7d25981cc5e3d23f70d9 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Sat, 1 Nov 2014 14:11:48 +0000 Subject: [PATCH] Issue #2363643 by ultimike | benjy: Fixed Nodes with format 0 are skipped. --- .../install/migrate.migration.d6_node.yml | 13 ++------- .../src/Plugin/migrate/source/d6/Node.php | 28 +++++++++++++++++++ .../src/Tests/d6/MigrateNodeTest.php | 4 +-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml index 1bf106245c75..790ecb55fb95 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_node.yml @@ -20,16 +20,9 @@ process: promote: promote sticky: sticky 'body/format': - - - plugin: static_map - bypass: true - source: format - map: - 0: NULL - - - plugin: migration - migration: d6_filter_format - no_stub: 1 + plugin: migration + migration: d6_filter_format + source: format 'body/value': body 'body/summary': teaser revision_uid: uid diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php index bdfa637dd636..3530a33b0941 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/Node.php @@ -7,6 +7,7 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source\d6; +use Drupal\migrate\Row; use Drupal\migrate\Plugin\SourceEntityInterface; use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; @@ -24,6 +25,13 @@ class Node extends DrupalSqlBase implements SourceEntityInterface { */ const JOIN = 'n.vid = nr.vid'; + /** + * The default filter format. + * + * @var string + */ + protected $filterDefaultFormat; + /** * {@inheritdoc} */ @@ -63,6 +71,14 @@ public function query() { return $query; } + /** + * {@inheritdoc} + */ + protected function runQuery() { + $this->filterDefaultFormat = $this->variableGet('filter_default_format', '1'); + return parent::runQuery(); + } + /** * {@inheritdoc} */ @@ -88,6 +104,18 @@ public function fields() { return $fields; } + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + // format = 0 can happen when the body field is hidden. Set the format to 1 + // to avoid migration map issues (since the body field isn't used anyway). + if ($row->getSourceProperty('format') === '0') { + $row->setSourceProperty('format', $this->filterDefaultFormat); + } + return parent::prepareRow($row); + } + /** * {@inheritdoc} */ diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTest.php index 4280bb560ef0..e3bed3a1d5c2 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTest.php @@ -87,8 +87,8 @@ public function testNode() { $this->assertEqual($node->body->format, 'full_html'); $node = Node::load(3); - // Test that format = 0 from source maps to NULL. - $this->assertIdentical($node->body->format, NULL); + // Test that format = 0 from source maps to filtered_html. + $this->assertIdentical($node->body->format, 'filtered_html'); } } -- GitLab