Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,12 @@ public function getIdsMatchingAnyTags(array $tags): array
return [];
}

$ids = [];
$idsPerTag = [];
foreach ($tags as $tag) {
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
$ids = array_merge($ids, $this->getTagIds($tag));
$idsPerTag[] = $this->getTagIds($tag);
}

return array_values(array_unique($ids));
return array_values(array_unique(array_merge(...$idsPerTag)));
}

/**
Expand Down Expand Up @@ -218,7 +217,7 @@ public function getIdsNotMatchingTags(array $tags): array
*/
private function getAllIds(): array
{
$allIds = [];
$idsPerTag = [];
$tagFiles = glob($this->tagDirectory . '*');

if ($tagFiles === false) {
Expand All @@ -227,14 +226,11 @@ private function getAllIds(): array

foreach ($tagFiles as $file) {
if (is_file($file)) {
$tag = basename($file);
$ids = $this->getTagIds($tag);
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
$allIds = array_merge($allIds, $ids);
$idsPerTag[] = $this->getTagIds(basename($file));
}
}

return array_values(array_unique($allIds));
return array_values(array_unique(array_merge(...$idsPerTag)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,16 @@ public function getIdsMatchingAnyTags(array $tags): array
// Matches Zend's implementation to prevent Redis slowdowns
// @see vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php line 777-778
if (count($tags) > self::SUNION_CHUNK_SIZE) {
$allIds = [];
$idsPerChunk = [];
$chunks = array_chunk($tags, self::SUNION_CHUNK_SIZE);

foreach ($chunks as $chunk) {
$tagKeys = array_map([$this, 'getTagKey'], $chunk);
$chunkIds = $this->redis->sUnion($tagKeys);
$chunkIds = is_array($chunkIds) ? $chunkIds : [];

// phpcs:ignore Magento2.Performance.ForeachArrayMerge
$allIds = array_merge($allIds, $chunkIds);
$idsPerChunk[] = is_array($chunkIds) ? $chunkIds : [];
}

return array_unique($allIds);
return array_unique(array_merge(...$idsPerChunk));
}

$tagKeys = array_map([$this, 'getTagKey'], $tags);
Expand Down