Skip to content

Commit f5ff61b

Browse files
committed
Fix slicing bug in MetaModel::getIdsFromFilter
The method `MetaModel::getIdsFromFilter` lost support for offset and limit when we introduced the id cache. The functionality has been restored.
1 parent 8a2f88d commit f5ff61b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/MetaModels/MetaModel.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,10 +729,16 @@ public function getIdsFromFilter($objFilter, $strSortBy = '', $intOffset = 0, $i
729729
// Build the right key for the cache.
730730
$sortKey = \sprintf('%s-%s', $strSortBy, \strtolower($strSortOrder));
731731
// Used the cached ID list, and make a list of wanted ID's with the sorting of the cache.
732-
$cacheResult = array_intersect((array) $this->existingIds[$sortKey], $arrFilteredIds);
732+
if (!isset($this->existingIds[$sortKey])) {
733+
$this->existingIds[$sortKey] = [];
734+
}
735+
$cacheResult = array_intersect($this->existingIds[$sortKey], $arrFilteredIds);
733736
// Check if we have all ID's or if we have one missing, now we are using the order of the MM Filter.
734737
if (array_intersect($arrFilteredIds, $cacheResult) === $arrFilteredIds) {
735-
return $cacheResult;
738+
if ($intOffset > 0 || $intLimit > 0) {
739+
return array_values(array_slice($cacheResult, $intOffset, $intLimit ?: null));
740+
}
741+
return array_values($cacheResult);
736742
}
737743

738744
// Merge the already known and the new one.

0 commit comments

Comments
 (0)