Hi, I was setting up a migration and not getting the correct sourceMigration (I was using the class name, not machine name). Running the result ended up with an exception with a not particularly helpful message.

I tracked this down to some code that assumes Migration::getInstance() succeeded, and so would try to call functions on (null).

I've attached one possible patch, which just checks that there is an object -- it works for me anyway. There's no need for a message: there is already a message in the buffer but it's not printed because of the exception. The second hunk in the diff is slightly unfortunate: it's just a new 'if ()', but the changed indentation makes it look bigger.

Hope this helps.

Comments

mikeryan’s picture

Status: Active » Needs review

Be sure to set the status to "Needs review" when submitting a patch for review.

Status: Needs review » Needs work

The last submitted patch, 0001-Make-Migrate-code-more-helpful-in-prescence-of-bad-s.patch, failed testing.

mikeryan’s picture

+++ b/migrate/includes/migration.inc
@@ -1377,6 +1377,10 @@ abstract class Migration extends MigrationBase {
+        MigrationBase::displayMessage(t('The @source cannot be resolved to a migration instance.',

If you unset $source_migrations[$key] here, you don't have to worry about checking for a valid $source_migration below. Alternatively, after this loop you can do $source_migrations = array_filter($source_migrations).

rivimey’s picture

I've rerolled the same patch with the patch filenames modified; hopefully this will now apply.

rivimey’s picture

mikeryan’s picture

Status: Needs work » Needs review

Be sure to set the status to "Needs review" for the testbot to test the changes, and alert humans there's a patch to review.

  • mikeryan committed 3a7972f on 7.x-2.x
    Issue #2536616 by rivimey,mikeryan: Improve message when sourceMigration...
mikeryan’s picture

Status: Needs review » Fixed

Committed (with the suggested improvment in #3), thanks!

mikeryan’s picture

Issue tags: +Migrate 2.9

Status: Fixed » Closed (fixed)

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