Commit 04978ffa authored by Zoltan Attila Horvath's avatar Zoltan Attila Horvath Committed by Zoltan Attila Horvath
Browse files

Issue #3291071 by huzooka: Avoid circular migration dependencies caused by...

Issue #3291071 by huzooka: Avoid circular migration dependencies caused by paragraphs and field collections types allowing to refer each other
parent 65d91265
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
        "source": "https://git.drupalcode.org/project/paragraphs_migration"
    },
    "require": {
        "drupal/migmag": "^1.3.0",
        "drupal/paragraphs": "^1.12",
        "drupal/smart_sql_idmap": "^1.1@beta"
    },
+3 −5
Original line number Diff line number Diff line
@@ -9,11 +9,9 @@ source:
  plugin: d7_pm_field_collection_item_revision
process:
  id_lookup:
    plugin: pm_paragraphs_lookup
    tags:
      - Field Collection Content
    plugin: migmag_lookup
    migration: d7_pm_field_collection
    source: item_id
    no_stub: true
  missing_revision_logging:
    source: '@id_lookup'
    plugin: skip_on_empty
@@ -23,7 +21,7 @@ process:
    plugin: extract
    source: '@id_lookup'
    index:
      - id
      - 0
  type:
    plugin: migration_lookup
    migration: d7_pm_field_collection_type
+3 −5
Original line number Diff line number Diff line
@@ -9,11 +9,9 @@ source:
  plugin: d7_pm_paragraphs_item_revision
process:
  id_lookup:
    plugin: pm_paragraphs_lookup
    tags:
      - Paragraphs Content
    plugin: migmag_lookup
    migration: d7_pm_paragraphs
    source: item_id
    no_stub: true
  missing_revision_logging:
    source: '@id_lookup'
    plugin: skip_on_empty
@@ -23,7 +21,7 @@ process:
    plugin: extract
    source: '@id_lookup'
    index:
      - id
      - 0
  type:
    plugin: migration_lookup
    migration: d7_pm_paragraphs_type
+1 −0
Original line number Diff line number Diff line
@@ -4,5 +4,6 @@ description: 'Drupal 7 to Drupal 8/9 migration path for the D7 Field Collection,
core_version_requirement: ^9
package: 'Migration'
dependencies:
  - migmag:migmag_process
  - paragraphs:paragraphs
  - smart_sql_idmap:smart_sql_idmap
 No newline at end of file
+5 −3
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
use Drupal\migrate\Plugin\MigrationDeriverTrait;
use Drupal\migrate\Row;
use Drupal\paragraphs_migration\Plugin\migrate\field\ParagraphsFieldPluginBase;

/**
 * Alters migrations for being compatible with paragraphs.
@@ -116,9 +117,10 @@ final class MigrationPluginsAlterer {
      }

      $paragraph_unfinalized_dependencies = $migration['source'][ParagraphsMigration::PARAGRAPHS_RAW_DEPENDENCIES] ?? [];
      $component_dependency_type = ParagraphsFieldPluginBase::getComponentDependencyType($migration['id'], $migration['source']);
      foreach ($paragraph_unfinalized_dependencies as $unfinalized_dependency) {
        if (($dep_key = array_search($unfinalized_dependency, $migration['migration_dependencies']['required'])) !== FALSE) {
          unset($migration['migration_dependencies']['required'][$dep_key]);
        if (($dep_key = array_search($unfinalized_dependency, $migration['migration_dependencies'][$component_dependency_type])) !== FALSE) {
          unset($migration['migration_dependencies'][$component_dependency_type][$dep_key]);
          $finalized_dependencies = array_reduce($migration_plugin_ids, function (array $carry, string $plugin_id) use ($unfinalized_dependency) {
            if (strpos($plugin_id, $unfinalized_dependency) === 0) {
              $carry[] = $plugin_id;
@@ -132,7 +134,7 @@ final class MigrationPluginsAlterer {
          if (($self_dep_key = array_search($migration_plugin_id, $finalized_dependencies)) !== FALSE) {
            unset($finalized_dependencies[$self_dep_key]);
          }
          $migration['migration_dependencies']['required'] = array_unique(array_merge($migration['migration_dependencies']['required'], $finalized_dependencies));
          $migration['migration_dependencies'][$component_dependency_type] = array_unique(array_merge($migration['migration_dependencies'][$component_dependency_type], $finalized_dependencies));
        }
      }
      unset($migration['source'][ParagraphsMigration::PARAGRAPHS_RAW_DEPENDENCIES]);
Loading