Skip to content

Commit

Permalink
Cache getPrev() and getNext() ID queries
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 14, 2024
1 parent 255dbe8 commit b8db7a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 4

## Unreleased

- Fixed a bug where elements’ `getPrev()` and `getNext()` methods could cause duplicate queries. ([#16329](https://github.com/craftcms/cms/discussions/16329))

## 4.13.6 - 2024-12-10

- Fixed a bug where blank user group descriptions weren’t getting omitted from project config data. ([#16272](https://github.com/craftcms/cms/pull/16272))
Expand Down
2 changes: 1 addition & 1 deletion src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -5500,7 +5500,7 @@ private function _getRelativeElement(mixed $criteria, int $dir): ?ElementInterfa
}

/** @var ElementQuery $query */
$elementIds = $query->ids();
$elementIds = $query->cache()->ids();
$key = array_search($this->getCanonicalId(), $elementIds, false);

if ($key === false || !isset($elementIds[$key + $dir])) {
Expand Down

0 comments on commit b8db7a7

Please sign in to comment.