Problem/Motivation
We are still migrating a Website from Drupal 6 to Drupal 8. After migrating a content-type with a link field I encountered this error when viewing the migrated node:
Error: Unsupported operand types in Drupal\Core\Utility\LinkGenerator->generate() (line 153 of core/lib/Drupal/Core/Utility/LinkGenerator.php).
After setting a breakpoint in transform() in Drupal\link\Plugin\migrate\process\FieldLink I noticed, that the link attributes got triple-serialized in our D6 page:
$value['attributes'] = 's:13:"s:6:"a:0:{}";";'
This seems to have happened to others too, but the other issue fixes the symptoms: https://www.drupal.org/project/drupal/issues/2596937
Proposed resolution
As I don’t think a triple-serialized value ever worked, my suggestion is to reset the attributes to an empty array in case it is not working after the first two unserialize-attempts.
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
Prevent link field migration from creating invalid link attributes.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | interdiff-3045211-8-15.txt | 777 bytes | yogeshmpawar |
| #15 | 3045211-15.patch | 2 KB | yogeshmpawar |
| #11 | 3045211-11.patch | 140.4 KB | nlisgo |
| #11 | interdiff_8-11.txt | 777 bytes | nlisgo |
| #8 | 3045211-8.patch | 2.02 KB | nlisgo |
Comments
Comment #2
nebel54Here is a patch
Comment #3
nebel54Comment #4
heddnNW because needs tests.
Comment #5
nlisgo commentedComment #7
heddnSmall nit only.
Row is a simple value object, no need to disable the constructor on it.
Comment #8
nlisgo commentedAddressing feedback in #7. Also, we can reuse the MigrateExecutableInterface and Row mocks.
Comment #9
heddnSuper nit: no need for a mock, just use the row object class directly.
new Row()Comment #10
nlisgo commentedComment #11
nlisgo commentedComment #12
heddnAll feedback addressed
Comment #13
quietone commentedSorry, something is amiss. The patch in #8 is 2K and the next one in #11 is 140K. Thats is a big difference with no explanation. Maybe the wrong patch? Not working from HEAD?
Comment #14
yogeshmpawarComment #15
yogeshmpawarAdded Updated patch with an interdiff.
Comment #16
heddnThanks Vicki, I only looked at the interdiff. Didn't notice the size of the patch. This looks more sane now.
Comment #17
nlisgo commentedApologies. I was juggling issues. Thanks @yogeshmpawar.
Comment #19
heddnComment #20
alexpottCommitted and pushed a71337b86f to 8.8.x and 7530980cf9 to 8.7.x. Thanks!
This can be made less complex.
if (!is_array($attributes)) {Made this change on commit because it is very minor.