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
When data for fields of type "link" are migrated from D6 to D8, if the link has no "attributes" value, it is incorrectly set to "false" in D8 (instead of an empty array) which causes an issue with LinkGenerator (see comment 16 of #2596937: Array merge failure on line 153 of core/lib/Drupal/Core/Utility/LinkGenerator.php).
Proposed resolution
Better handling of the attributes data in the d6_cck_link process plugin.
Remaining tasks
Review the patch, suggest better ways to handle (than the attached patch). Add a test.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff-2633568-9-11.txt | 697 bytes | quietone |
#11 | 2633568-11.patch | 2.37 KB | quietone |
#9 | 2633568-9.patch | 2.22 KB | quietone |
#9 | 2633568-9-fail.patch | 1.57 KB | quietone |
#4 | interdiff-2633568-0-4.txt | 1.32 KB | quietone |
Comments
Comment #2
ultimikeComment #3
quietone CreditAttribution: quietone commentedComment #4
quietone CreditAttribution: quietone as a volunteer commentedTesting showed that if the attribute valid is NULL or '', then this does fail. This failure will whenever the attribute data is not a serialized string causing unserialize to return FALSE. Not sure why there would be unserializable data in that field. I wasn't able to get erroneous data in the attributes field through the UI and the source isn't mentioned in the IS. Still, we need to test it and make sure that $route['options']['attributes'] has meaningful data.
Tests have been added to MigrateNodeTest for the link values. There are a couples of patches here because I added 'bad' data to the attribute field in the test fixture for testing.
The attached patches
Note I never hit the breakpoint set in core/lib/Drupal/Core/Utility/LinkGenerator.php perhaps because I was testing with d6/MigrateNodeTest.
Comment #5
quietone CreditAttribution: quietone as a volunteer commentedComment #8
benjy CreditAttribution: benjy at PreviousNext commentedWe need to leave the bad source data otherwise we're not actually testing the original issue. Also, super small issue I noticed below:
Bad indent on this line.
Comment #9
quietone CreditAttribution: quietone as a volunteer commentedWell, don't know what I was thinking, definitely took the wrong path. Anyway, this should be a fail patch and fix.
thx benjy.
Comment #11
quietone CreditAttribution: quietone as a volunteer commentedAdded a comment.
Comment #12
benjy CreditAttribution: benjy at PreviousNext commentedLooks good to me.
Comment #13
catchCommitted/pushed to all three 8.x branches, thanks!