From c332eff2108e3fa72938c17885479e66c91fca29 Mon Sep 17 00:00:00 2001 From: Maurice Hildebrandt Date: Wed, 10 Jun 2026 14:09:31 +0200 Subject: [PATCH] Fix order() error if structure contains null item When calling order() on an entry and the structure contains, for whatever reason, a `null` item, it would result in a fatal error from array_flip(). This commit makes the order() call more robust. Fixes #14801 --- src/Entries/Entry.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index 406cd62d75a..1340ff4a70f 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -528,10 +528,13 @@ public function order() return $this->value('order'); } - return $this->structure()->in($this->locale()) + $order = $this->structure()->in($this->locale()) ->flattenedPages() ->map->reference() - ->flip()->get($this->id) + 1; + ->filter() + ->flip()->get($this->id); + + return $order !== null ? $order + 1 : null; } public function template($template = null)