Issue #2363643 by ultimike | benjy: Fixed Nodes with format 0 are skipped.
parent
9872c3ae14
commit
392522c083
|
@ -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
|
||||
|
|
|
@ -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 @@ class Node extends DrupalSqlBase implements SourceEntityInterface {
|
|||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function runQuery() {
|
||||
$this->filterDefaultFormat = $this->variableGet('filter_default_format', '1');
|
||||
return parent::runQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -88,6 +104,18 @@ class Node extends DrupalSqlBase implements SourceEntityInterface {
|
|||
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}
|
||||
*/
|
||||
|
|
|
@ -87,8 +87,8 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
$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');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue