Need to deep merge options for compatibility with other modules
Problem/Motivation
Follow-up on #3331630: Compatibility with other modules, options being overwritten.
I just read the code in the commit and I think it might instead need an array_merge_deep so that all values are preserved and the second array does not override the first one?
For example for attributes:
<?php
$a = [
'attributes' => ['class' => ['a']],
];
$b = [
'attributes' => ['class' => ['a']],
];
$c = array_merge($a, $b);
?>
will result in
array(1) {
["attributes"]=>
array(1) {
["class"]=>
array(1) {
[0]=>
string(1) "b"
}
}
}but I think we need to preserve all values here.
This may also lead to conflicts, if one attribute *should* override, but I don't think we can handle that!
Steps to reproduce
Proposed resolution
Remaining tasks
- Discuss:
- Use array_merge
- Use array_merge_recursive
- Use one of https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Utility%21NestedArray.php/class/NestedArray/10
- Only merge certain attributes recursively
- Implement
- Test
- Release
User interface changes
API changes
Data model changes
Edited by drupalbot