From 3276d4b61176ee6f8b372689511f6b3e7c20c40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Wed, 8 Jan 2020 08:43:02 +0100 Subject: [PATCH] Fix an edge case in sorting --- libs/Tree/Directory.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libs/Tree/Directory.php b/libs/Tree/Directory.php index f3d6b7a..7ab4451 100644 --- a/libs/Tree/Directory.php +++ b/libs/Tree/Directory.php @@ -26,14 +26,24 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate ]; foreach ($this->children as $key => $entry) { + // In case of generated pages, the name might be empty. + // Thus we are falling back to other solutions, otherwise the page would disappear from the tree. $name = $entry->getName(); - if ($name == 'index' || $name == '_index') { - $buckets['index'][$key] = $entry; - continue; + if (!$name) { + $name = $entry->getTitle(); } if (!$name) { + $name = $key; + } + + if (!$name) { + continue; + } + + if ($name == 'index' || $name == '_index') { + $buckets['index'][$key] = $entry; continue; }