Skip to content

Commit

Permalink
Backport #16124
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Nov 18, 2024
1 parent fbb05a3 commit 6b0c951
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fixed a JavaScript error that could occur on element edit pages. ([#16055](https://github.com/craftcms/cms/issues/16055))
- Fixed a Twig deprecation error. ([#16107](https://github.com/craftcms/cms/issues/16107))
- Fixed a bug where `craft\services\Structures::fillGapsInElements()` wasn’t working properly if the elements weren’t passed in hierarchical order. ([#16085](https://github.com/craftcms/cms/issues/16085))

## 4.13.0 - 2024-11-12

Expand Down
4 changes: 4 additions & 0 deletions src/services/Structures.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ public function fillGapsInElements(array &$elements): void
$prevElement = null;
$patchedElements = [];

// https://github.com/craftcms/cms/issues/16085
// don't assume that elements are in the top to bottom order
usort($elements, fn(ElementInterface $a, ElementInterface $b) => $a->lft <=> $b->lft);

foreach ($elements as $i => $element) {
// Did we just skip any elements?
if (
Expand Down

0 comments on commit 6b0c951

Please sign in to comment.