Warning: Undefined array key "node_type" in workbench_moderation_migrate.module on line 80

Created on 22 January 2023, almost 2 years ago

Problem/Motivation

When using Workbench Moderation Migrate, the presence of a migration which has a destination.plugin of entity_complete:node and does not have a value for source.node_type (eg, source is not derived from d7_node / Drupal\node\Plugin\migrate\source\d7\Node) will cause an "undefined array key 'node_type'" warning.

A minimal example to reproduce might look like:

source:
  plugin: 'content_entity:node'
  bundle: page
destination:
  plugin: 'entity_complete:node'
  default_bundle: page

id: whatever
process:
  whatever: whatever

Such a migration need not be intended for processing by Workbench Moderation Migrate; in our case it's a secondary migration which exists in the system configuration for execution when the D7 to D9 migrations are completed.

Steps to reproduce

  1. Have a migration which uses Workbench Moderation Migrate
  2. Also have a migration configured which has destination="entity_complete:node" and source is NOT "d7_node_complete" or a derivative
  3. Execute drush migrate:status after a cache clear

Proposed resolution

Handle the case where there is no $definition['source']['node_type'] defined on a migration.

Remaining tasks

Review & merge

API changes

I believe the changes in MR4 preserve existing behaviour while preventing the warning.

๐Ÿ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

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

Comments & Activities

  • Issue created by @xurizaemon
  • @xurizaemon opened merge request.
  • @xurizaemon opened merge request.
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    An example of a migration which triggers this behaviour is a migration which has a source plugin of "content_entity:node" and shares a site with migrations using Workbench Moderation Migrate (eg "d7_node_complete" or derivatives.

    The relevant block of code is https://git.drupalcode.org/project/workbench_moderation_migrate/-/blob/6...

    "content_entity:node" is a source which Workbench Moderation Migrate should skip. The array filter finds migrations with a destination of "entity_complete:node", but does not realise that the source is not either "d7_node_complete" or a derivative thereof.

    The current behaviour was to set $node_type to NULL (which means no workflow will be found), and this MR retains that but does it explicitly.

    MR!4 includes both fix and changes to make the behaviour show up with tests.

    MR!5 has only the test changes (adding some migrations which trigger this behaviour when run through workbench_moderation_migrate_migration_plugins_alter(), which shows up in tests output).

  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ
Production build 0.71.5 2024