Ensure that the shared_configuration option doesn't recursively merge the Url source plugin's urls

Created on 23 October 2023, almost 2 years ago

Problem/Motivation

If the migration group contains the following shared configuration entry:

shared_configuration:
  source:
    plugin: url
    urls:
      - 'private://file-1.jsonlines'
      - 'private://file-2.jsonlines'
      - 'private://file-3.jsonlines'

And an individual migration contains the following:

source:
  plugin: url
  urls:
    - 'private://overridden-file-entry.jsonlines'

The final output becomes this:

source:
  plugin: url
  urls:
    - 'private://overridden-file-entry.jsonlines'
    - 'private://file-2.jsonlines'
    - 'private://file-3.jsonlines'

But should contain only the single original entry.

Steps to reproduce

Proposed resolution

Persist the original urls if they exist in the original migration.

An alternative is to introduce a new #merge_options property within the shared_configuration property which controls whether certain entries should be merged or not (I believe most list arrays should typically be left unmerged).

Remaining tasks

Provide issue fork/patch.

User interface changes

N/A

📌 Task
Status

Active

Version

6.0

Component

Miscellaneous

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @codebymikey
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update almost 2 years ago
    195 pass
  • @codebymikey opened merge request.
  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work 3 months ago
  • heddn Nicaragua
    +++ b/migrate_plus.module
    @@ -78,6 +79,11 @@ function migrate_plus_migration_plugins_alter(array &$migrations): void {
    +    if ($source_urls && $migrations[$id]['source']['plugin'] === 'url') {
    

    We should check on the class level. If someone does a custom url class that extends migrate_plus, this wouldn't catch it. But if this did a class instanceof check, then we'd be fine.

Production build 0.71.5 2024