Commit fcc5f3b2 authored by webchick's avatar webchick

Issue #2263453 by chx, benjy: Split migration_dependencies into two keys.

parent 49b4f933
......@@ -20,34 +20,28 @@ class MigrationStorage extends ConfigEntityStorage implements MigrateBuildDepend
*/
public function buildDependencyMigration(array $migrations, array $dynamic_ids) {
// Migration dependencies defined in the migration storage can be
// soft dependencies: if a soft dependency does not run, the current
// migration is still OK to go. This is indicated by adding ": false"
// (without quotes) after the name of the dependency. Hard dependencies
// (default) are called requirements. Both hard and soft dependencies (if
// run at all) must run before the current one.
// optional or required. If an optional dependency does not run, the current
// migration is still OK to go. Both optional and required dependencies
// (if run at all) must run before the current migration.
$dependency_graph = array();
$requirement_graph = array();
$different = FALSE;
foreach ($migrations as $migration) {
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
/** @var \Drupal\migrate\Entity\Migration $migration */
$id = $migration->id();
$requirements[$id] = array();
$dependency_graph[$id]['edges'] = array();
if (isset($migration->migration_dependencies) && is_array($migration->migration_dependencies)) {
foreach ($migration->migration_dependencies as $dependency) {
if (is_string($dependency) && !isset($dynamic_ids[$dependency])) {
if (isset($migration->migration_dependencies['required'])) {
foreach ($migration->migration_dependencies['required'] as $dependency) {
if (!isset($dynamic_ids[$dependency])) {
$this->addDependency($requirement_graph, $id, $dependency, $dynamic_ids);
}
if (is_array($dependency)) {
list($dependency_string, $required) = each($dependency);
$dependency = $dependency_string;
if ($required) {
$this->addDependency($requirement_graph, $id, $dependency, $dynamic_ids);
}
else {
$different = TRUE;
}
}
$this->addDependency($dependency_graph, $id, $dependency, $dynamic_ids);
}
}
if (isset($migration->migration_dependencies['optional'])) {
foreach ($migration->migration_dependencies['optional'] as $dependency) {
$different = TRUE;
$this->addDependency($dependency_graph, $id, $dependency, $dynamic_ids);
}
}
......
......@@ -14,6 +14,9 @@
use Drupal\migrate\Row;
/**
* Every migration that uses this destination must have an optional
* dependency on the d6_file migration to ensure it runs first.
*
* @MigrateDestination(
* id = "entity:file"
* )
......
......@@ -18,4 +18,5 @@ process:
destination:
plugin: entity:aggregator_item
migration_dependencies:
- d6_aggregator_feed
required:
- d6_aggregator_feed
......@@ -58,5 +58,7 @@ process:
destination:
plugin: entity:block
migration_dependencies:
- d6_custom_block
- d6_menu: false
required:
- d6_custom_block
optional:
- d6_menu
......@@ -16,4 +16,5 @@ process:
destination:
plugin: book
migration_dependencies:
- d6_node
required:
- d6_node
......@@ -10,5 +10,6 @@ process:
destination:
plugin: entity_revision:node
migration_dependencies:
- d6_cck_field_values
- d6_node_revision
required:
- d6_cck_field_values
- d6_node_revision
......@@ -13,6 +13,7 @@ process:
destination:
plugin: entity:node
migration_dependencies:
- d6_node
- d6_field_formatter_settings
- d6_field_instance_widget_settings
required:
- d6_node
- d6_field_formatter_settings
- d6_field_instance_widget_settings
......@@ -44,8 +44,9 @@ process:
destination:
plugin: entity:comment
migration_dependencies:
- d6_node
- d6_user
- d6_comment_entity_display
- d6_comment_entity_form_display
- d6_filter_format
required:
- d6_node
- d6_user
- d6_comment_entity_display
- d6_comment_entity_form_display
- d6_filter_format
......@@ -20,4 +20,5 @@ process:
destination:
plugin: component_entity_display
migration_dependencies:
- d6_comment_field_instance
required:
- d6_comment_field_instance
......@@ -19,4 +19,5 @@ process:
destination:
plugin: component_entity_form_display
migration_dependencies:
- d6_comment_field_instance
required:
- d6_comment_field_instance
......@@ -24,5 +24,6 @@ process:
destination:
plugin: entity:field_instance_config
migration_dependencies:
- d6_comment_field
- d6_node_type
required:
- d6_comment_field
- d6_node_type
......@@ -16,4 +16,5 @@ process:
destination:
plugin: entity:custom_block
migration_dependencies:
- d6_filter_format
required:
- d6_filter_format
......@@ -77,7 +77,8 @@ process:
destination:
plugin: entity:field_config
migration_dependencies:
# It is not possible to make this a requirement as d6_field_settings has no
# source id. However it also has no requirements so it will always run so a
# dependency is enough.
- d6_field_settings: false
optional:
# It is not possible to make this required as d6_field_settings has no
# source id. However it also has no required dependencies so it will always
# run so an optional dependency is enough.
- d6_field_settings
......@@ -294,5 +294,6 @@ process:
destination:
plugin: component_entity_display
migration_dependencies:
- d6_field_instance
- d6_view_modes
required:
- d6_field_instance
- d6_view_modes
......@@ -44,5 +44,6 @@ process:
destination:
plugin: entity:field_instance_config
migration_dependencies:
- d6_node_type
- d6_field
required:
- d6_node_type
- d6_field
......@@ -54,4 +54,5 @@ process:
destination:
plugin: component_entity_form_display
migration_dependencies:
- d6_field_instance
required:
- d6_field_instance
# Every migration that saves into {file_managed} must have the d6_file
# migration as an optional dependency to ensure d6_file runs first.
id: d6_file
label: Drupal 6 files
source:
......
......@@ -29,8 +29,10 @@ process:
destination:
plugin: entity:node
migration_dependencies:
- d6_node_type
- d6_filter_format
- d6_field_instance_widget_settings: false
- d6_field_formatter_settings: false
- d6_node_settings: false
required:
- d6_node_type
- d6_filter_format
optional:
- d6_field_instance_widget_settings
- d6_field_formatter_settings
- d6_node_settings
......@@ -29,4 +29,5 @@ process:
destination:
plugin: entity_revision:node
migration_dependencies:
- d6_node
required:
- d6_node
......@@ -10,4 +10,5 @@ destination:
plugin: config
config_name: node.settings
migration_dependencies:
- d6_node_type
required:
- d6_node_type
......@@ -12,7 +12,8 @@ process:
destination:
plugin: entity:user
migration_dependencies:
- d6_user
- d6_user_profile_field_instance
- d6_user_profile_entity_display
- d6_user_profile_entity_form_display
required:
- d6_user
- d6_user_profile_field_instance
- d6_user_profile_entity_display
- d6_user_profile_entity_form_display
......@@ -22,4 +22,5 @@ process:
destination:
plugin: entity:taxonomy_term
migration_dependencies:
- d6_taxonomy_vocabulary
required:
- d6_taxonomy_vocabulary
......@@ -14,6 +14,7 @@ process:
destination:
plugin: entity:node
migration_dependencies:
- d6_vocabulary_entity_display
- d6_vocabulary_entity_form_display
- d6_node
required:
- d6_vocabulary_entity_display
- d6_vocabulary_entity_form_display
- d6_node
......@@ -14,5 +14,6 @@ process:
destination:
plugin: entity_revision:node
migration_dependencies:
- d6_term_node
- d6_node_revision
required:
- d6_term_node
- d6_node_revision
......@@ -19,5 +19,6 @@ process:
destination:
plugin: entity:node
migration_dependencies:
- d6_file
- d6_node
required:
- d6_file
- d6_node
......@@ -21,4 +21,5 @@ process:
destination:
plugin: component_entity_display
migration_dependencies:
- d6_upload_field_instance
required:
- d6_upload_field_instance
......@@ -23,4 +23,5 @@ process:
destination:
plugin: component_entity_form_display
migration_dependencies:
- d6_upload_field_instance
required:
- d6_upload_field_instance
......@@ -17,5 +17,6 @@ process:
destination:
plugin: entity:field_instance_config
migration_dependencies:
- d6_upload_field
- d6_node_type
required:
- d6_upload_field
- d6_node_type
......@@ -33,8 +33,10 @@ destination:
plugin: entity:user
md5_passwords: true
migration_dependencies:
- d6_filter_format
- d6_user_role
- d6_user_picture_entity_display
- d6_user_picture_entity_form_display
- d6_user_picture_file: false
required:
- d6_filter_format
- d6_user_role
- d6_user_picture_entity_display
- d6_user_picture_entity_form_display
optional:
- d6_user_picture_file
......@@ -24,4 +24,5 @@ process:
destination:
plugin: component_entity_display
migration_dependencies:
- d6_user_picture_field_instance
required:
- d6_user_picture_field_instance
......@@ -24,4 +24,5 @@ process:
destination:
plugin: component_entity_form_display
migration_dependencies:
- d6_user_picture_field_instance
required:
- d6_user_picture_field_instance
......@@ -24,4 +24,5 @@ process:
destination:
plugin: entity:field_instance_config
migration_dependencies:
- d6_user_picture_field
required:
- d6_user_picture_field
......@@ -16,4 +16,7 @@ destination:
plugin: entity:file
source_path_property: picture
migration_dependencies:
- d6_file: false
# Every migration that saves into {file_managed} must have the d6_file
# migration as an optional dependency to ensure it runs first.
optional:
- d6_file
......@@ -15,4 +15,5 @@ process:
destination:
plugin: entity:field_instance_config
migration_dependencies:
- d6_user_profile_field
required:
- d6_user_profile_field
......@@ -22,4 +22,5 @@ process:
destination:
plugin: component_entity_display
migration_dependencies:
- d6_vocabulary_field_instance
required:
- d6_vocabulary_field_instance
......@@ -20,4 +20,5 @@ process:
destination:
plugin: component_entity_form_display
migration_dependencies:
- d6_vocabulary_field_instance
required:
- d6_vocabulary_field_instance
......@@ -20,4 +20,5 @@ process:
destination:
plugin: entity:field_config
migration_dependencies:
- d6_taxonomy_vocabulary
required:
- d6_taxonomy_vocabulary
......@@ -17,4 +17,5 @@ process:
destination:
plugin: entity:field_instance_config
migration_dependencies:
- d6_vocabulary_field
required:
- d6_vocabulary_field
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment