Issue #3045211 by nlisgo, yogeshmpawar, Nebel54, heddn, quietone: Prevent link field migration from creating invalid link attributes

merge-requests/1119/head
Alex Pott 2019-05-29 10:41:42 +01:00
parent 070e49b1a5
commit a71337b86f
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 26 additions and 1 deletions

View File

@ -119,7 +119,9 @@ class FieldLink extends ProcessPluginBase {
$attributes = unserialize($attributes);
}
if (!$attributes) {
// In rare cases Drupal 6/7 link attributes are triple serialized. To avoid
// further problems with them we set them to an empty array in this case.
if (!is_array($attributes)) {
$attributes = [];
}

View File

@ -89,4 +89,27 @@ class FieldLinkTest extends UnitTestCase {
];
}
/**
* Test the attributes that are deeply serialized are discarded.
*/
public function testCanonicalizeUriSerialized() {
$link_plugin = new FieldLink([], '', [], $this->getMock(MigrationInterface::class));
$migrate_executable = $this->getMock(MigrateExecutableInterface::class);
$row = new Row();
$transformed = $link_plugin->transform([
'url' => '',
'title' => '',
'attributes' => serialize(serialize(['not too deep'])),
], $migrate_executable, $row, NULL);
$this->assertEquals(['not too deep'], $transformed['options']['attributes']);
$transformed = $link_plugin->transform([
'url' => '',
'title' => '',
'attributes' => serialize(serialize(serialize(['too deep']))),
], $migrate_executable, $row, NULL);
$this->assertEmpty($transformed['options']['attributes']);
}
}