Problem/Motivation
Merge unique does not seem to be working. All of the rest of the merge types work, it is ... uniquely... the unique merge type.
Steps to reproduce
When I debug the preRenderMergeUnique function here:
if (!empty($rendered_row[$field_name]) && !\in_array($rendered_row[$field_name], $merged_row[$field_name])) {
$merged_row[$field_name][] = $rendered_row[$field_name];
}
It's doing an in_array with an array of \Drupal\Core\Render\Markup objects. I believe this in_array comparison with the strict setting will always return FALSE.
Example:
$needle = t('Test');
$haystack = [t('Test')];
$result1 = in_array($needle, $haystack); // Returns TRUE
$result2 = in_array($needle, $haystack, TRUE); // Returns FALSE
$needle = 'Test';
$haystack = ['Test'];
$result3 = in_array($needle, $haystack); // Returns TRUE
$result4 = in_array($needle, $haystack, TRUE); // Returns TRUE
Proposed resolution
I have a patch that just adds another function to convert the markup objects to strings. This isn't the best solution, but I need it for now.
Remaining tasks
User interface changes
API changes
Data model changes