Problem/Motivation
In Issue #3236774, it was discovered that the ability to reference the current value of a process pipeline already existed but was undocumented. Specifically, migration process plugins that accept multiple source properties (like concat, callback, download, etc.) can reference the current pipeline value by using null as a source parameter.
This feature works through the get plugin's hidden behavior: when $property is null, an empty string, or an empty array, the plugin returns the current pipeline value. However, this capability is not documented in the official API documentation.
Example usage:
process: processed_value: - plugin: callable source: field_product callable: ucfirst - plugin: concat source: - 'constants/i' - null # References current pipeline value
As noted in comment #9, any falsey value except the string '0' would work to get the pipeline value, not just null. This suggests the documentation may be incomplete.
Steps to reproduce
N/A - This is a documentation issue.
Proposed resolution
Add documentation to the code itself to explain how to reference the current pipeline value. This documentation will feed into the API documentation page that is linked from the list of migration plugins.
The documentation should clarify:
- That
nullcan be used to reference the current pipeline value - The behavior of other falsey values (empty string, empty array, etc.) and whether they should also be documented or if only
nullis the recommended approach - The implications for other plugins that accept source properties
This documentation enhancement requires subsystem maintainer review to ensure accuracy and completeness, particularly regarding the behavior of falsey values beyond null.
Remaining tasks
- Subsystem maintainer review of the proposed documentation to confirm whether only
nullshould be documented or if other falsey values are also valid/recommended - Clarify implications for other plugins accepting source properties
- Review and finalize MR !13995
- Update documentation in code
- Commit the changes
User interface changes
None.
API changes
None. This is a documentation-only change.
Data model changes
None.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3560542
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:
- 3560542-11-x
changes, plain diff MR !13995
- 3560542-improve-documentation-for
changes, plain diff MR !13991
Comments
Comment #3
jan kellermann commentedAdded documentation in code. Please review and feedback.
Comment #4
jan kellermann commentedComment #5
smustgrave commentedHave not reviewed but MRs need to be against 11.x as the current development branch
If you are another contributor eager to jump in, please allow the previous poster(s) at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
Comment #8
jan kellermann commentedSorry, created MR against 11.x.
Comment #9
dcam commentedThank you for your suggestion to improve Drupal!
I looked over the
Getplugin code. It seems like any falsey value except the string'0'* would work to get the pipeline value, not just NULL. This is just an educated guess; I haven't tested it. So these new docs may be incomplete. Also, this could have implications for other plugins that accept lists of source properties. I'm tagging it for subsystem maintainer review to get an opinion.It is preferred for issues to have the entire summary template with all headings, even if some sections are left empty. So I'm tagging this for needing a summary update and setting the status to Needs Work.
*There's a condition to allow the string
'0'as a property name.Comment #11
batigolixWith a bit of AI agent help, I updated the summary
Comment #12
batigolixI addressed the feedback from #9
I also simplified the example and made it more similar to the other @code example in this plugin.
Comment #13
danflanagan8Good find by @dcam that
falsehas the same effect asnull.And the new example looks correct.
But I think before this "weird trick" is officially documented, I think someone needs to confirm that there is test coverage somewhere. I don't recall ever looking into that.
Comment #14
smustgrave commentedSo looking around I do see any test coverage around this plugin, so guess we need to add some
Comment #15
quietone commentedAll the migrate process plugins in the Migrate module have tests. They are at core/modules/migrate/tests/src/Unit/process.
In effect, this is documenting how the Get plugin works by using Concat as the example. In that regard I am not convinced this extra documentation is needed here. And I don't want to set a precedence such that similar examples are added to all the other process plugin.
Instead, I would rather improve the Get process documentation. It already has something for this behavior but it is buried in the examples. So. at least move this text to before the examples.
I am leaving the "Needs subsystem maintainer review" tag to allow the other maintainers to express a view.
Comment #16
needs-review-queue-bot commentedThe 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.
Comment #17
smustgrave commentedFairly positive this is a false positive
Comment #18
smustgrave commentedSince it's been 2+ weeks think we should follow what @quietone suggested in #15
Thanks!
Comment #19
drupal.ninja03 commentedI checked core/modules/migrate/src/Plugin/migrate/process/Get.php on the main branch as per comment#15 & #18.
The behavior mentioned in the issue is already documented there, but it is currently placed after the list-of-source-properties example:
"If the list of source properties contains an empty element then the current value will be used. This makes it impossible to reach a source property with an empty string as its name."
Based on comment #15, I agree that the current MR does not fully incorporate the feedback yet because it documents the behavior in Concat.php, while the behavior belongs to the Get process plugin.
A better next step may be to move/expand the existing Get.php explanation before the examples, so the current pipeline value behavior is easier to discover, without adding concat-specific examples that could set a precedent for documenting this in every process plugin.
Leaving as Needs work.
Comment #20
drupal.ninja03 commentedUpdated the MR to address the feedback in #15 and #18.
Changes made:
- Moved/expanded the documentation for using the current process pipeline value to Get.php, where this behavior belongs.
- Placed the explanation before the examples so it is easier to discover.
- Removed the concat-specific pipeline value example from Concat.php to avoid documenting Get plugin behavior in individual process plugins.
- Fixed the existing Concat.php delimiter example typo where the 'bar' value should be "Parks".
Setting back to Needs review.
Comment #21
smustgrave commented@quietone as a migration maintainer thoughts?
Comment #22
nicxvan commentedThis looks like all feedback has been addressed and is a good update to the docs.
@quietone left the subsystem maintainer tag, but it's been 7 months, I think it's safe to move to the next step.
Comment #28
quietone commentedThanks everyone! As subsystem maintainer I have removed the tag. This does make it clearer how the get plugin behaves.
Committed and pushed to all branches as a documentation improvements are allowed.