For my custom migration, I tried using the migmag_lookup plugin, since the Drupal core migration_lookup does not work as intended for me.

However, when using this plugin I get the following error:

PHP Fatal error: Trait 'Drupal\migrate_drupal\MigrationConfigurationTrait' not found in /app/web/modules/contrib/migmag/migmag_process/src/Plugin/migrate/process/MigMagLookup.php on line 123

By enabling the migrate_drupal module, this error is resolved. However this module was not enabled in my case, since my migrations do not use Drupal as a source.

It seems it would be to more user friendly to add migrate_drupal as a dependency in the relevant (sub)modules' .info.yml file - at least the ones that use logic from that module.

Obviously the core migrate module could also be added as a module dependency, which is currently not the case, but it wouldn't make much sense to use migmag without it, whereas using migmag without migrate_drupal is a perfectly fine use case.

Comments

svendecabooter created an issue. See original summary.

svendecabooter’s picture

Actually, using migmag without migrate_drupal is probably not a valid use case after all.
In my case I am using a JSON data source (via migrate_plus contrib module), and wanted better stubbing logic than the default migration_lookup provides.
But it seems migmag_lookup assumes a database source for the migration, so does not work for me.

Might be good to document that this is a requirement, as I did not understand that from the doc page at https://www.drupal.org/docs/contributed-modules/migrate-magician/migrate...

codebymikey’s picture

Recently ran into this bug myself while importing a custom JSON lines source using migrate_plus's API, the core issues this module solves relating to stubs is pretty useful irrespective of the source and it'd be nice if it worked with non-database sources as well, good to know though.

huzooka’s picture

Tbh I should reevaluate why I though I need Migrate Drupal here… or why I am using it.

huzooka’s picture

Assigned: Unassigned » huzooka

Let's see what's going on here...

huzooka’s picture

This is the test-only patch. It took a while figuring out why Drupal\migrate_drupal\MigrationConfigurationTrait was available during testing while on a "real" environment it shouldn't be loadable... It happens because of this: #2006476: Strengthen tests by not autoregistering non-test namespaces of disabled modules.

I spent my yesterday exploring and understanding the problem, and I also published a workaround: Test Classmap Cleanup (for PHPUnit tests)

@svendecabooter, I hope that the attached test-only patch will make the lookup test fail with the same error what you have... Let's see!

huzooka’s picture

Status: Active » Needs work

Let's change the status to NW!

huzooka’s picture

Status: Needs work » Needs review
StatusFileSize
new4.5 KB
new5.47 KB

The fix-only patch is the inderdiff between #6 and #8

Status: Needs review » Needs work
huzooka’s picture

Status: Needs work » Needs review
StatusFileSize
new371 bytes

🧐

huzooka’s picture

huzooka’s picture

Title: Define dependency on migrate_drupal » [PP-1] Define dependency on migrate_drupal
Status: Needs review » Postponed
huzooka’s picture

Title: [PP-1] Define dependency on migrate_drupal » MigMagLookup shouldn't (implicitly) depend on Migrate Drupal
Status: Postponed » Needs review
StatusFileSize
new996 bytes
new5.47 KB

Test only patch should be identical to #6, complete patch must be identical to #11.

  • huzooka committed ff3c569 on 1.8.x
    Issue #3294768 by huzooka, svendecabooter, codebymikey: MigMagLookup...
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs review » Fixed

🥳

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.