Problem/Motivation

In the parent issue, we plan to add the methods addRequiredDependencies() and addOptionalDependencies() to Drupal\migrate\Plugin\Migration. This issue is to add those two methods now, instead of waiting for the parent issue.

The reason is that we have already removed the option of calling getMigrationDependencies() without expanding dependencies. Some contrib modules use the pattern

    $dependencies = $migration->getMigrationDependencies() + ['required' => []];
    $dependencies['required'] = array_unique(array_merge(array_values($dependencies['required']), [$migration_dependency]));
    $migration->set('migration_dependencies', $dependencies);

in a deriver (or in code that gets called from a deriver). That can lead to an infinite loop.

Steps to reproduce

See #3433816: Automated Drupal 11 compatibility fixes for paragraphs.

Proposed resolution

Copy the code for addRequiredDependencies() and addOptionalDependencies() from the parent issue.

Remaining tasks

Review
Review change record

User interface changes

None

Introduced terminology

None

API changes

Add two public methods to Drupal\migrate\Plugin\Migration.

For BC reasons, do not add the new methods to the interface in this issue, but add them in a follow-up issue or in the parent issue.

Data model changes

None

Release notes snippet

N/A

CommentFileSizeAuthor
#17 3464320-nr-bot.txt2.8 KBneeds-review-queue-bot

Issue fork drupal-3464320

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

benjifisher created an issue. See original summary.

benjifisher’s picture

Another possibility: the current code both deprecates calling getMigrationDependencies() with the $expand parameter and ignores that parameter if it is provided. Maybe we should deprecate it but not ignore it. Then a contrib module could call getMigrationDependencies(FALSE) to avoid the recursion.

We might do this in addition to the proposed resolution in the issue summary.

benjifisher’s picture

Status: Active » Needs review
benjifisher’s picture

Assigned: benjifisher » Unassigned
catch’s picture

This looks fine to me, adding to the interface should be OK under the 1-1 rule, but is the intention to backport this to 11.0/10.4 too? If so it might make sense to be extra extra cautious.

benjifisher’s picture

... is the intention to backport this to 11.0/10.4 too?

I think that calling getMigrationDependencies(FALSE) is deprecated in 10.4.x but triggers an error in 11.0.x, so I would like to backport this to the 11.0.x branch. Or maybe it is only deprecated in 11.x, so module maintainers remove it so their tests can pass, but then they get the infinite loop. One way or another, it is worse in 11.x (and probably 11.0.x) than in 10.4.x.

From the issue summary:

For BC reasons, do not add the new methods to the interface in this issue, but add them in a follow-up issue or in the parent issue.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs change record

Left some nitpicky threads on the MR.

But for the new methods should a CR be written.

With my limited migration eyes the rest looks good though.

quietone made their first commit to this issue’s fork.

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs change record

The test failure is MigrateNoMigrateDrupalTest.php which is soon to be fixed by #3466289: MigrateNoMigrateDrupalTest fails with missing classes in certain situations.

I added a CR, applied existing suggestions, and added 2 of my own.

benjifisher’s picture

I added an example to the CR based on the changes in core/modules/migrate_drupal/src/Plugin/migrate/field/ReferenceBase.php.

The code changes look good to me, but I cannot declare the issue RTBC since I did the initial work on the PR. Since I extracted the new code from the old work on the parent issue, it is not surprising that I missed the return-type declarations. I am surprised that my initial version passed static analysis. I guess that is because many existing functions do not have return-type declarations, so we do not require them in static analysis.

smustgrave’s picture

    1)
    Drupal\Tests\migrate\Functional\MigrateNoMigrateDrupalTest::testExecutionNoMigrateDrupal
    Behat\Mink\Exception\ResponseTextException: The text "Migration was
    successful." was not found anywhere in the text of the current page.
    
    /builds/project/drupal/vendor/behat/mink/src/WebAssert.php:907
    /builds/project/drupal/vendor/behat/mink/src/WebAssert.php:293
    /builds/project/drupal/core/tests/Drupal/Tests/WebAssert.php:979
    /builds/project/drupal/core/modules/migrate/tests/src/Functional/MigrateNoMigrateDrupalTest.php:50
    
    FAILURES!

May be related?

quietone’s picture

Although it is a migration test it is not related to the additions made here.

Unfortunately, I can't RTBC this either as I wrote much of the code in the originating issue this was taken from, #2796755: [PP-1] Deprecate Migration::set().

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Did another lap and believe all feedback has been addressed.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

MigrateNoMigrateDrupalTest::testExecutionNoMigrateDrupal is failing.

benjifisher’s picture

Status: Needs work » Reviewed & tested by the community

I rebased on the current 11.x branch. In particular, the feature branch now includes the fix for #3466289: MigrateNoMigrateDrupalTest fails with missing classes in certain situations. As @quietone predicted (#10, #13), that fixes the failing test.

Given that I did not do any new coding, I am making an exception to the usual practice: back to RTBC.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new2.8 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

benjifisher’s picture

Status: Needs work » Needs review

I added the missing return types in the unit test (void for the test methods and array for the data providers). Back to NR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe feedback for this one has been addressed, around test failure and review bot.

  • catch committed d5d9a9ba on 11.x
    Issue #3464320 by benjifisher, quietone, smustgrave: Drupal\migrate\...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks!

Status: Fixed » Closed (fixed)

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

heddn’s picture

The addition of this seems to have added an infinite loop via field discovery calling getMigrationDependencies. Will start looking for a bug report, but wanted to mention this here in case someone else has already surfaced this.