Active
Project:
Drupal core
Version:
main
Component:
cache system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Sep 2026 at 16:45 UTC
Updated:
21 Sep 2026 at 18:05 UTC
Jump to comment: Most recent
The line $cache_tags = array_values(array_unique(array_merge(...$cache_tags))); inside Drupal's \Drupal\Core\Cache\Cache::mergeTags function can cause performance bottlenecks when handling massive arrays because array_merge with the unpacking operator (...) and array_unique process every single item linearly in memory.
The issue is not limited to this scenario. It can happen when the drupal site runs on a slower cpu/memory system when using the function mergeTags with a lot of cache tags.
Optimize the code below in \Drupal\Core\Cache\Cache::mergeTags
$cache_tags = array_values(array_unique(array_merge(...$cache_tags)));
Comments
Comment #2
longwaveI think this is a duplicate of #3395304: Merging cache metadata is slow with thousands of tags added.