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
Content of custom fields on Users is not migrating from D7 to D8 on the first pass. It does migrate if Users (and nothing else) is rolled back and re-migrated. This appears to be because the fields and field instances are not migrated until after the users.
Proposed resolution
Ensure fields and field instances are migrated before users.
Remaining tasks
Add d7_field_instance (and consequently d7_field) as a migration dependency of d7_user (as it is for d7_node).
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#17 | d7_user_fields_not_migrating-2674152-17.patch | 7.86 KB | jofitz |
#17 | interdiff.txt | 901 bytes | jofitz |
Comments
Comment #2
jofitz CreditAttribution: jofitz commentedAdd d7_field_instance to the migration dependencies of d7_user.
Comment #3
quietone CreditAttribution: quietone as a volunteer commentedComment #4
benjy CreditAttribution: benjy at PreviousNext commentedCan we add a couple of tests here please.
Comment #6
jofitz CreditAttribution: jofitz commentedChecked with v8.1.1.
Comment #7
jofitz CreditAttribution: jofitz at ComputerMinds commented@benjy I'm not sure how to add tests for this seeing as migrations and their ordering is hard-coded in functional tests. I cannot think of a test that will fail without this patch and then pass with it. Any suggestions?
(Also version corrected)
Comment #8
benjy CreditAttribution: benjy at PreviousNext commentedCould we add some assertions to
\Drupal\Tests\user\Kernel\Migrate\d7\MigrateUserTest
for some of the user field data?Comment #9
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdded tests to MigrateUserTest.
N.B. Test user language changed from '' (empty string) to 'en' because fields (with a language) cannot be associated with users without a language (see #2671312: No default value for User langcode when migrating D7 users with no language: No default value for User langcode when migrating D7 users with no language).
(now has a lot of code in common with #2673960: Unable to migrate D7 User cck fields, unsurprisingly)
Comment #10
hussainwebI see this issue was created 5 months ago and it might not be working then but I can't get it to reproduce right now. I downloaded the latest 8.2.x, enabled a few basic modules, and migrated from my D7 site which has two fields on user. They did get migrated the first time:
The field instance settings didn't get migrated but that's handled in another issue - #2675470: D7 field instance settings for any fields not on nodes are not migrating. The tests in here could be useful but I think there are identical tests in many other issues.
Comment #13
mikeryan@hussainweb - the OP may be a bit ambiguous - the fields and their instances do get created on migration, but after the users are migrated, thus the field *content* is not populated on users. I've reproduced this locally.
Comment #14
jofitz CreditAttribution: jofitz at ComputerMinds commentedClarification of title and summary.
In process of re-rolling.
Comment #15
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-rolled.
Comment #17
jofitz CreditAttribution: jofitz at ComputerMinds commentedResolve test failure.
Comment #19
mikeryanI'm amused by this, given the actual fix is 1 line...
Anyway, looks good to me, RTBC, thanks!
Comment #22
catchCommitted/pushed to 8.3.x and 8.2.x, thanks!
Also retrospectively bumping to major and 'migrate critical' since this would result in data loss for a one-hit migration via the UI.