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
A custom migration might need a lot of very small custom process plugins for their properties. This results in an astonishing amount of boilerplate as most process plugins are 1-5 lines of code with 30+ lines of boilerplate.
Proposed resolution
Make it possible to call any method in a process plugin. As a demo, convert the two skip on empty plugins into one.
Remaining tasks
Document this in the handbook.
User interface changes
API changes
Minimal. If you used these two plugins then run sed -i -f 2509496_sed.txt *
in the directory where your configs are and you are set.
Data model changes
Do we need to write an upgrade hook for migrate? I am wondering. If we need to, of course I can.
Comment | File | Size | Author |
---|---|---|---|
#14 | 2509496_14.patch | 12.44 KB | chx |
#14 | interdiff.txt | 1.34 KB | chx |
#8 | 2509496_sed.txt | 158 bytes | chx |
Comments
Comment #2
chx CreditAttribution: chx commentedComment #4
chx CreditAttribution: chx commentedComment #5
chx CreditAttribution: chx commentedComment #6
chx CreditAttribution: chx commentedTypofix
Comment #7
benjy CreditAttribution: benjy at CodeDrop commentedI've reviewed this a couple of times today and we discussed the approach on IRC. I think this is a nice pattern and a good simplification of the skip process plugins.
Comment #8
chx CreditAttribution: chx commentedComment #9
phenaproximaI'm ambivalent about having configuration specify which method to call, but OTOH I'm all for reducing boilerplate. So +1 for this.
However...
The exception should include a message.
The doc comment is misleading. It skips the processing if the value is falsy/empty, not just 0.
There is no check that the method actually exists and is callable. Should there be a bit of validation here, and an exception thrown if $configuration['method'] is invalid? To that end, isset() should probably be !empty().
Comment #10
chx CreditAttribution: chx commentedComment #13
benjy CreditAttribution: benjy at CodeDrop commentedCan we add the non-existent method name to the exception message?
Comment #14
chx CreditAttribution: chx commentedComment #15
benjy CreditAttribution: benjy at CodeDrop commentedGreat!
Comment #16
alexpottMigrate is not subject beta evaluations. Committed 8d3755c and pushed to 8.0.x. Thanks!