Issue #2281553 by benjy, Sutharsan, ultimate: D6->D8 Node Revision migration is incomplete.

8.0.x
webchick 2014-09-22 21:35:22 -07:00
parent 2c1fe04e6f
commit dfecbdd429
8 changed files with 69 additions and 15 deletions

View File

@ -8,13 +8,15 @@ process:
nid: nid
vid: vid
type: type
langcode: language
langcode:
plugin: default_value
source: language
default_value: "und"
title: title
uid: uid
status: status
created: created
changed: changed
revision_timestamp: timestamp
promote: promote
sticky: sticky
'body/format':
@ -22,6 +24,10 @@ process:
migration: d6_filter_format
source: format
'body/value': body
'body/summary': teaser
revision_uid: uid
revision_log: log
revision_timestamp: timestamp
# unmapped d6 fields.
# tnid

View File

@ -8,7 +8,10 @@ process:
nid: nid
vid: vid
type: type
langcode: language
langcode:
plugin: default_value
source: language
default_value: "und"
title: title
uid: uid
status: status
@ -21,6 +24,10 @@ process:
migration: d6_filter_format
source: format
'body/value': body
'body/summary': teaser
revision_uid: uid
revision_log: log
revision_timestamp: timestamp
# unmapped d6 fields.
# tnid

View File

@ -50,8 +50,9 @@ class Node extends DrupalSqlBase implements SourceEntityInterface {
'title',
'body',
'teaser',
'format',
'log',
'timestamp',
'format',
));
$query->innerJoin('node', 'n', static::JOIN);
@ -76,7 +77,6 @@ class Node extends DrupalSqlBase implements SourceEntityInterface {
'promote' => $this->t('Promoted to front page'),
'sticky' => $this->t('Sticky at top of lists'),
'revision' => $this->t('Create new revision'),
'log' => $this->t('Revision Log message'),
'language' => $this->t('Language (fr, en, ...)'),
'tnid' => $this->t('The translation set id for this node'),
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),

View File

@ -26,7 +26,11 @@ class NodeRevision extends Node {
*/
public function fields() {
// Use all the node fields plus the vid that identifies the version.
return parent::fields() + array('vid' => t('The primary identifier for this version.'));
return parent::fields() + array(
'vid' => t('The primary identifier for this version.'),
'log' => $this->t('Revision Log message'),
'timestamp' => $this->t('Revision timestamp'),
);
}
/**

View File

@ -31,10 +31,21 @@ class Drupal6NodeRevision extends Drupal6DumpBase {
'vid' => 2,
'uid' => 2,
'title' => 'Test title rev 2',
'body' => 'test rev 2',
'teaser' => 'test rev 2',
'log' => '',
'timestamp' => 1390095701,
'body' => 'body test rev 2',
'teaser' => 'teaser test rev 2',
'log' => 'modified rev 2',
'timestamp' => 1390095702,
'format' => 1,
))
->values(array(
'nid' => 1,
'vid' => 4,
'uid' => 1,
'title' => 'Test title rev 3',
'body' => 'body test rev 3',
'teaser' => 'teaser test rev 3',
'log' => 'modified rev 3',
'timestamp' => 1390095703,
'format' => 1,
))
->execute();

View File

@ -43,9 +43,23 @@ class MigrateNodeRevisionTest extends MigrateNodeTestBase {
*/
public function testNodeRevision() {
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
/** @var \Drupal\node\NodeInterface $node */
$this->assertEqual($node->id(), 1);
$this->assertEqual($node->getRevisionId(), 2);
$this->assertEqual($node->body->value, 'test rev 2');
$this->assertEqual($node->langcode->value, 'und');
$this->assertEqual($node->getTitle(), 'Test title rev 2');
$this->assertEqual($node->body->value, 'body test rev 2');
$this->assertEqual($node->body->summary, 'teaser test rev 2');
$this->assertEqual($node->getRevisionAuthor()->id(), 1);
$this->assertEqual($node->revision_log->value, 'modified rev 2');
$this->assertEqual($node->getRevisionCreationTime(), '1390095702');
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(4);
$this->assertEqual($node->id(), 1);
$this->assertEqual($node->body->value, 'body test rev 3');
$this->assertEqual($node->getRevisionAuthor()->id(), 1);
$this->assertEqual($node->revision_log->value, 'modified rev 3');
$this->assertEqual($node->getRevisionCreationTime(), '1390095703');
}
}

View File

@ -38,7 +38,9 @@ class MigrateNodeTest extends MigrateNodeTestBase {
public function testNode() {
$node = node_load(1);
$this->assertEqual($node->id(), 1, 'Node 1 loaded.');
$this->assertEqual($node->langcode->value, 'und');
$this->assertEqual($node->body->value, 'test');
$this->assertEqual($node->body->summary, 'test');
$this->assertEqual($node->body->format, 'filtered_html');
$this->assertEqual($node->getType(), 'story', 'Node has the correct bundle.');
$this->assertEqual($node->getTitle(), 'Test title', 'Node has the correct title.');
@ -47,6 +49,13 @@ class MigrateNodeTest extends MigrateNodeTestBase {
$this->assertEqual($node->getOwnerId(), 1);
$this->assertEqual($node->getRevisionCreationTime(), 1390095701, 'Node has the correct revision timestamp.');
/** @var \Drupal\node\NodeInterface $node_revision */
$node_revision = \Drupal::entityManager()->getStorage('node')->loadRevision(1);
$this->assertEqual($node_revision->getTitle(), 'Test title');
$this->assertEqual($node_revision->getRevisionAuthor()->id(), 1, 'Node revision has the correct user');
// This is empty on the first revision.
$this->assertEqual($node_revision->revision_log->value, '');
// It is pointless to run the second half from MigrateDrupal6Test.
if (empty($this->standalone)) {
return;

View File

@ -40,7 +40,6 @@ class NodeTest extends MigrateSqlSourceTestCase {
'title' => 'node title 1',
'uid' => 1,
'status' => 1,
'timestamp' => 1279051598,
'created' => 1279051598,
'changed' => 1279051598,
'comment' => 2,
@ -52,6 +51,8 @@ class NodeTest extends MigrateSqlSourceTestCase {
// Node revision fields.
'body' => 'body for node 1',
'teaser' => 'teaser for node 1',
'log' => '',
'timestamp' => 1279051598,
'format' => 1,
),
array(
@ -63,7 +64,6 @@ class NodeTest extends MigrateSqlSourceTestCase {
'title' => 'node title 2',
'uid' => 1,
'status' => 1,
'timestamp' => 1279290908,
'created' => 1279290908,
'changed' => 1279308993,
'comment' => 0,
@ -75,6 +75,8 @@ class NodeTest extends MigrateSqlSourceTestCase {
// Node revision fields.
'body' => 'body for node 2',
'teaser' => 'teaser for node 2',
'log' => '',
'timestamp' => 1279308993,
'format' => 1,
),
array(
@ -86,7 +88,6 @@ class NodeTest extends MigrateSqlSourceTestCase {
'title' => 'node title 5',
'uid' => 1,
'status' => 1,
'timestamp' => 1279290908,
'created' => 1279290908,
'changed' => 1279308993,
'comment' => 0,
@ -98,6 +99,8 @@ class NodeTest extends MigrateSqlSourceTestCase {
// Node revision fields.
'body' => 'body for node 5',
'teaser' => 'body for node 5',
'log' => '',
'timestamp' => 1279308993,
'format' => 1,
),
);
@ -107,7 +110,7 @@ class NodeTest extends MigrateSqlSourceTestCase {
*/
protected function setUp() {
foreach ($this->expectedResults as $k => $row) {
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'format', 'timestamp') as $i => $field) {
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'log', 'timestamp', 'format') as $i => $field) {
$this->databaseContents['node_revisions'][$k][$field] = $row[$field];
// Keep nid and vid.
if ($i > 1) {