Commit ec9a3ec2 authored by alexpott's avatar alexpott

Issue #2348875 by benjy, chx, bdone: Improving our dump files

parent 7d013683
......@@ -102,7 +102,7 @@ process:
filefield:
default: file_default
url_plain: file_url_plain
path_plain: file_url_plan #unsure about this?
path_plain: file_url_plain
image_plain: image
image_nodelink: image
image_imagelink: image
......
......@@ -112,21 +112,26 @@ public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = N
];
}
elseif ($data['type'] === 'text') {
$migration->process[$field_name . '/value'] = $field_name . '/value';
// The data is stored differently depending on whether we're using
// db storage.
$value_key = $data['db_storage'] ? $field_name : "$field_name/value";
$format_key = $data['db_storage'] ? $field_name . '_format' : "$field_name/format" ;
$migration->process["$field_name/value"] = $value_key;
// See d6_user, signature_format for an example of the YAML that
// represents this process array.
$migration->process[$field_name . '/format'] = [
$migration->process["$field_name/format"] = [
[
'plugin' => 'static_map',
'bypass' => TRUE,
'source' => $field_name . '/format',
'source' => $format_key,
'map' => [0 => NULL]
],
['plugin' => 'skip_process_on_empty'],
[
'plugin' => 'migration',
'migration' => 'd6_filter_format',
'source' => $field_name . '/format',
'source' => $format_key,
'no_stub' => 1,
],
];
......
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\Dump\Drupal6ActionSettings.
*/
namespace Drupal\migrate_drupal\Tests\Dump;
/**
* Database dump for testing action.settings.yml migration.
*/
class Drupal6ActionSettings extends Drupal6DumpBase {
/**
* {@inheritdoc}
*/
public function load() {
$this->createTable('variable');
$this->database->insert('variable')->fields(array(
'name',
'value',
))
->values(array(
'name' => 'actions_max_stack',
'value' => 'i:35;',
))
->execute();
}
}
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\Dump\Drupal6AggregatorSettings.
*/
namespace Drupal\migrate_drupal\Tests\Dump;
/**
* Database dump for testing aggregator.settings.yml migration.
*/
class Drupal6AggregatorSettings extends Drupal6DumpBase {
/**
* {@inheritdoc}
*/
public function load() {
$this->createTable('variable');
$this->database->insert('variable')->fields(array(
'name',
'value',
))
->values(array(
'name' => 'aggregator_fetcher',
'value' => 's:10:"aggregator";',
))
->values(array(
'name' => 'aggregator_parser',
'value' => 's:10:"aggregator";',
))
->values(array(
'name' => 'aggregator_processors',
'value' => 'a:1:{i:0;s:10:"aggregator";}',
))
->values(array(
'name' => 'aggregator_allowed_html_tags',
'value' => 's:70:"<a> <b> <br /> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>";',
))
->values(array(
'name' => 'aggregator_teaser_length',
'value' => 's:3:"600";',
))
->values(array(
'name' => 'aggregator_clear',
'value' => 's:7:"9676800";',
))
->values(array(
'name' => 'aggregator_summary_items',
'value' => 's:1:"3";',
))
->execute();
}
}
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\Dump\Drupal6BookSettings.
*/
namespace Drupal\migrate_drupal\Tests\Dump;
/**
* Database dump for testing book.settings.yml migration.
*/
class Drupal6BookSettings extends Drupal6DumpBase {
/**
* {@inheritdoc}
*/
public function load() {
$this->createTable('variable');
$this->database->insert('variable')->fields(array(
'name',
'value',
))
->values(array(
'name' => 'book_allowed_types',
'value' => 'a:1:{i:0;s:4:"book";}',
))
->values(array(
'name' => 'book_block_mode',
'value' => 's:9:"all pages";',
))
->values(array(
'name' => 'book_child_type',
'value' => 's:4:"book";',
))
->execute();
}
}
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\Dump\Drupal6ContactCategories.
*/
namespace Drupal\migrate_drupal\Tests\Dump;
/**
* Database dump for testing contact category migration.
*/
class Drupal6ContactCategory extends Drupal6DumpBase {
/**
* {@inheritdoc}
*/
public function load() {
$this->createTable('contact', array(
'description' => 'Contact form category settings.',
'fields' => array(
'cid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique category ID.',
),
'category' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Category name.',
'translatable' => TRUE,
),
'recipients' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Comma-separated list of recipient email addresses.',
),
'reply' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Text of the auto-reply message.',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => "The category's weight.",
),
'selected' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)',
),
),
'primary key' => array('cid'),
'unique keys' => array(
'category' => array('category'),
),
'indexes' => array(
'list' => array('weight', 'category'),
),
));
$this->database->insert('contact')->fields(array('cid', 'category', 'recipients', 'reply', 'weight', 'selected'))
->values(array(
'cid' => '1',
'category' => 'Website feedback',
'recipients' => 'admin@example.com',
'reply' => '',
'weight' => '0',
'selected' => '0',
))
->values(array(
'cid' => '2',
'category' => 'Some other category',
'recipients' => 'test@example.com',
'reply' => 'Thanks for contacting us, we will reply ASAP!',
'weight' => '1',
'selected' => '1',
))
->values(array(
'cid' => '3',
'category' => 'A category much longer than thirty two characters',
'recipients' => 'fortyninechars@example.com',
'reply' => '',
'weight' => '2',
'selected' => '0',
))
->execute();
$this->setModuleVersion('contact', '6001');
}
}
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\Dump\Drupal6ContactSettings.
*/
namespace Drupal\migrate_drupal\Tests\Dump;
/**
* Database dump for testing contact.settings.yml migration.
*/
class Drupal6ContactSettings extends Drupal6DumpBase {
/**
* {@inheritdoc}
*/
public function load() {
$this->createTable('variable');
$this->database->insert('variable')->fields(array(
'name',
'value',
))
->values(array(
'name' => 'contact_default_status',
'value' => 'i:1;',
))
->values(array(
'name' => 'contact_hourly_threshold',
'value' => 'i:3;',
))
->execute();
}
}
<?php
namespace Drupal\migrate_drupal\Tests\Dump;
/**
* Database dump for testing date formats migration.
*/
class Drupal6DateFormat extends Drupal6DumpBase {
/**
* {@inheritdoc}
*/
public function load() {
$this->createTable('variable');
$this->database->insert('variable')->fields(array(
'name',
'value',
))
->values(array(
'name' => 'date_format_long',
'value' => 's:24:"\\L\\O\\N\\G l, F j, Y - H:i";',
))
->values(array(
'name' => 'date_format_medium',
'value' => 's:27:"\\M\\E\\D\\I\\U\\M D, m/d/Y - H:i";',
))
->values(array(
'name' => 'date_format_short',
'value' => 's:22:"\\S\\H\\O\\R\\T m/d/Y - H:i";',
))
->execute();
}
}
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\Dump\Drupal6DblogSettings.
*/
namespace Drupal\migrate_drupal\Tests\Dump;
/**
* Database dump for testing dblog.settings.yml migration.
*/
class Drupal6DblogSettings extends Drupal6DumpBase {
/**
* {@inheritdoc}
*/
public function load() {
$this->createTable('variable');
$this->database->insert('variable')->fields(array(
'name',
'value',
))
->values(array(
'name' => 'dblog_row_limit',
'value' => 'i:1000;',
))
->execute();
}
}
......@@ -6,6 +6,7 @@
*/
namespace Drupal\migrate_drupal\Tests\Dump;
use Drupal\Core\Database\Connection;
/**
......@@ -20,6 +21,13 @@ class Drupal6DumpBase {
*/
protected $database;
/**
* An array of tables that have already been created.
*
* @var array
*/
protected $migrateTables;
/**
* Sample database schema and values.
*
......@@ -33,219 +41,17 @@ public function __construct(Connection $database) {
/**
* Create a new table from a Drupal table definition if it doesn't exist.
*
* @param $name
* @param string $name
* The name of the table to create.
* @param $table
* @param array $table
* A Schema API table definition array.
*/
protected function createTable($name, $table = NULL) {
protected function createTable($name, array $table) {
// This must be on the database connection to be shared among classes.
if (empty($this->database->migrateTables[$name])) {
$this->database->migrateTables[$name] = TRUE;
$this->database->schema()->createTable($name, $table ?: $this->tableDefinitions()[$name]);
$this->database->schema()->createTable($name, $table);
}
}
/**
* Table definitions.
*/
protected function tableDefinitions() {
return array(
'node_type' => array(
'description' => 'Stores information about all defined {node} types.',
'fields' => array(
'type' => array(
'description' => 'The machine-readable name of this type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE),
'name' => array(
'description' => 'The human-readable name of this type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'module' => array(
'description' => 'The base string used to construct callbacks corresponding to this node type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE),
'description' => array(
'description' => 'A brief description of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium'),
'help' => array(
'description' => 'Help information shown to the user when creating a {node} of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium'),
'has_title' => array(
'description' => 'Boolean indicating whether this type uses the {node}.title field.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'size' => 'tiny'),
'title_label' => array(
'description' => 'The label displayed for the title field on the edit form.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'has_body' => array(
'description' => 'Boolean indicating whether this type uses the {node_revisions}.body field.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'size' => 'tiny'),
'body_label' => array(
'description' => 'The label displayed for the body field on the edit form.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'min_word_count' => array(
'description' => 'The minimum number of words the body must contain.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'size' => 'small'),
'custom' => array(
'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via a module like the Content Construction Kit (TRUE).',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny'),
'modified' => array(
'description' => 'A boolean indicating whether this type has been modified by an administrator; currently not used in any way.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny'),
'locked' => array(
'description' => 'A boolean indicating whether the administrator can change the machine name of this type.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny'),
'orig_type' => array(
'description' => 'The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('type'),
),
'variable' => array(
'fields' => array(
'name' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'value' => array(
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'translatable' => TRUE,
),
),
'primary key' => array(
'name',
),
'module' => 'book',
'name' => 'variable',
),
'system' => array(
'description' => "A list of all modules, themes, and theme engines that are or have been installed in Drupal's file system.",
'fields' => array(
'filename' => array(
'description' => 'The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'name' => array(
'description' => 'The name of the item; e.g. node.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'type' => array(
'description' => 'The type of the item, either module, theme, or theme_engine.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'owner' => array(
'description' => "A theme's 'parent'. Can be either a theme or an engine.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'status' => array(
'description' => 'Boolean indicating whether or not this item is enabled.',
'type' => 'int',
'not null' => TRUE,
'default' => 0),
'throttle' => array(
'description' => 'Boolean indicating whether this item is disabled when the throttle.module disables throttleable items.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny'),
'bootstrap' => array(
'description' => "Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted).",
'type' => 'int'