Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The $migration
argument of \Drupal\migrate\Plugin\MigrateDestinationInterface::fields
is
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Unused, will be removed before Drupal 9.0.x. Defaults to NULL.
This was added in #2543568: Remove the md_entity destination plugin hack.
Proposed resolution
Work out what to do.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff.txt | 1.19 KB | andypost |
#10 | 3114974-10.patch | 7.77 KB | andypost |
Comments
Comment #2
kishor_kolekar CreditAttribution: kishor_kolekar as a volunteer and at QED42 for Drupal India Association commentedComment #3
kishor_kolekar CreditAttribution: kishor_kolekar as a volunteer and at QED42 for Drupal India Association commentedRemoved the argument from the method fields() from the interface MigrateDestinationInterface and from all its implementations.
please review the patch.
Comment #4
alexpottWe don't need to add it :)
The big questions to be worked out is a) why does this exist - it does not appear to be called from core code and b) it is used by contrib migrate projects in anyway?
Comment #5
andypostIt was decided useless in #2543568: Remove the md_entity destination plugin hack
Checked in contrib and migrate tools does not use the argument
Here's a patch to re-roll and remove mentions
Comment #6
kishor_kolekar CreditAttribution: kishor_kolekar as a volunteer and at QED42 for Drupal India Association commentedhi @alexpott I have found this has been used in migrate_plus and field_group contrib module .
Comment #7
mikelutzShockingly, I think this is actually okay to go ahead and do. Yes, migrate_plus and field_group, and any other module that defines a destination plugin does have the argument in their method signature --- they have to, it's in the interface. However neither of them use the argument --- they can't, we never pass it when we call the method. This is all okay. You can add optional arguments to an method with a defined interface in php, so their function signatures are still valid if we remove the argument from the interface. Likewise, if someone somewhere for some reason happens to call this method and pass a migration, it's still fine, you can call a method with extra arguments and they will be ignored. If somewhere in contrib land someone used this parameter in the method and had code that called it with a migration, it's still fine. That would just keep working.
We lucked out in that the parameter is defined as optional in the original interface, because of that we can actually safely remove it. There really wouldn't be a way to trigger an error to deprecate removing a parameter from an interface anyway, so at the end of the day I say we commit this to 9.0 and move on if we can get RM blessing on the rather odd removal.
Comment #8
mikelutzComment #10
andypostFix CS
Comment #11
andypostComment #12
mikelutzThis was RTBC just got bumped back from testbot. Back to RTBC
Comment #14
andypostComment #16
catchIf we had a base class here or similar, we could trigger a deprecation notice when the unnecessary parameter is passed. However we don't have that, and adding the logic to every implementation seems like overkill here.
One problem as pointed out by @alexpott in slack is that if we added a new parameter to the method in 10.x it would conflict with passing the old parameter in. In that case we'd need to do stage adding the method via func_get_args() with a deprecation notice, but I think we tackle that if we get there - adding a new param to an interface is tricky anyway.
Committed 9cf5c69 and pushed to 9.1.x. Thanks!