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
#2671312: No default value for User langcode when migrating D7 users with no language requires a migration process plugin that returns a config value by default if there is no value to migrate (i.e. NULL).
Proposed resolution
The process plugin has already been written as part of #2671312: No default value for User langcode when migrating D7 users with no language, but it is recommended to separate it into it's own issue.
Remaining tasks
The plugin also needs tests.
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#23 | interdiff_19-22.txt | 1.72 KB | jofitz |
#22 | 2752281-22.patch | 4.7 KB | jofitz |
Comments
Comment #2
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdd process plugin.
Comment #3
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdd test for plugin (including adding dependency injection to the plugin).
Comment #4
jofitz CreditAttribution: jofitz at ComputerMinds commentedComment #5
benjy CreditAttribution: benjy at PreviousNext commentedun-needed comment.
> 80 chars.
This is wrong, we need to use ContainerInjectionInterface and inject just the dependencies we need. See
Drupal\block\Plugin\migrate\process\BlockVisibility
for an example.un-needed comment
Comment #6
jofitz CreditAttribution: jofitz at ComputerMinds commentedAddressed comments in @benjy's code review.
Comment #7
benjy CreditAttribution: benjy at PreviousNext commentedPatch looks good, just one small nitpick and then RTBC.
Normally, we inject new parameters at the end.
Comment #8
jofitz CreditAttribution: jofitz at ComputerMinds commentedMade corrections according to code review.
Comment #10
jofitz CreditAttribution: jofitz at ComputerMinds commentedComment #11
benjy CreditAttribution: benjy at PreviousNext commentedMissing comments, bit pointless I know but we need them for phpcs.
Comment #12
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdded missing comments on methods.
Comment #13
benjy CreditAttribution: benjy at PreviousNext commentedSorry to keep pushing this back on docs but the committers won't commit it unless it's right as there is an effort to make Drupal core pass an automated coding standard check. It's worthwhile making yourself familiar with the standards: https://www.drupal.org/coding-standards
These need comments and types.
This needs a comment.
Comment #14
jofitz CreditAttribution: jofitz at ComputerMinds commentedNo problem, I must make sure I get these things right. Comments improved.
Comment #15
benjy CreditAttribution: benjy at PreviousNext commentedThanks for sticking with it, I think this is ready. I'd be happy for this to go in core although I can't ever see it been used in the upgrade path from d6/d7 it will be useful for others using the generic Migrate API.
This could probably be fixed on commit per: https://www.drupal.org/coding-standards/docs#types it needs to be bool and not boolean.
Comment #17
jofitz CreditAttribution: jofitz at ComputerMinds commentedNow passing tests again, assume there were testbot issues. Setting back to RTBC.
@benjy RE use in d6/d7 upgrade path: I have another patch, #2671312: No default value for User langcode when migrating D7 users with no language, waiting on this one before it can progress.
Comment #18
alexpottThis type of test looks like it could use the @dataProvider pattern.
This undoes what setUp is doing - not sure the setUp method is necessary should just be part of the test that needs it.
Again could use the @dataProvider pattern.
I think this could be replaced with $this->getConfigFactoryStub() in setUp()
Comment #19
alexpottHere's a patch showing what I'm on about. Also discovered that the process plugin was typehinting on ConfigFactory and not ConfigFactoryInterface (as it should be).
Comment #20
quietone CreditAttribution: quietone as a volunteer commentedWhy is there both a strict and not strict version? Can you give an example where each is needed?
Does this need @param in the docblock?
I think it would be clearer to also include tests with different results. That is, have a source of empty string or 0.
Removed the tag since this is not D7->D8 specific.
Comment #21
chx CreditAttribution: chx at Smartsheet commentedThe more of think of this issue the more it unravels.
DefaultValue::transform()
and that's it).Comment #22
jofitz CreditAttribution: jofitz at ComputerMinds commentedResponse to @quietone:
@param
sI will address @chx's remarks in another comment.
Comment #23
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdded previously malformed interdiff.
Comment #24
jofitz CreditAttribution: jofitz at ComputerMinds commentedI think @chx makes many valid points, I can see the reasoning and I agree with most if not all of the assertions; it might be preferable to separate config_value into its own plugin & somehow combine that with default_value and I am interested in the concept of a kind of source constant.
On the other hand, the absence of the functionality provided by this plugin has been delaying the correction of a fundamental flaw in migration (#2671312: No default value for User langcode when migrating D7 users with no language) since February. In turn, that flaw is delaying at least one issue (#2563649: Migrations: Metatag-D7 basic entities) and impacting other (core) issues (e.g. #2673960: Unable to migrate D7 User cck fields & #2674152: D7 User fields content not migrating first time).
As a compromise, I suggest committing this patch as "deprecated" while simultaneously opening another ticket to work towards an ideal solution, as requested by @chx. This will allow other dependent work to continue, while working towards an eventual solution acceptable to all.
Comment #25
jofitz CreditAttribution: jofitz at ComputerMinds commentedWould someone mind responding to my suggestion, please? It's been a fortnight and it would be good to get this (and the related issues) moving. I am open to alternative suggestions.
Comment #27
phenaproximaI am of two minds about this, but because it's basically an API improvement at this point and not (to my knowledge) blocking anything critical, I find myself leaning more in the direction of what @chx proposes.
I would suggest that we change DefaultValue to support this behavior. Let's add two new configuration options:
from_property
andfrom_config
.from_property
would utilize an injected Get plugin instance and could therefore be used this way:from_config
would use an injected ConfigFactoryInterface and would be configured thusly:What do y'all think?
Comment #28
jofitz CreditAttribution: jofitz at ComputerMinds commentedNow that #2671312: No default value for User langcode when migrating D7 users with no language has been closed I don't think this change is necessary, but I'm happy to leave this open if there are other applications.
Comment #29
phenaproximaIf you think this change is obviated, then we can wontfix this. Thank you! :)