From 0cee7bcdc893d88dc752d8f71572950d408c02a9 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 2 Dec 2020 10:41:10 +0200 Subject: [PATCH] Fixed Page ordering to be natural and case insensitive --- CHANGELOG.md | 2 +- system/src/Grav/Common/Flex/Types/Pages/PageCollection.php | 2 +- .../Grav/Common/Flex/Types/Pages/Storage/PageStorage.php | 6 +++--- system/src/Grav/Common/Page/Pages.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cfce60b0..fcd85c50a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ * Fixed `|safe_email` filter to return safe and escaped UTF-8 HTML [#3072](https://github.com/getgrav/grav/issues/3072) * Fixed exception in CLI GPM and backup commands when `php-zip` is not enabled [#3075](https://github.com/getgrav/grav/issues/3075) * Fix for XSS advisory [GHSA-cvmr-6428-87w9](https://github.com/getgrav/grav/security/advisories/GHSA-cvmr-6428-87w9) - * Fixed Flex ordering to be natural and case insensitive [flex-objects#87](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/87) + * Fixed Flex and Page ordering to be natural and case insensitive [flex-objects#87](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/87) # v1.7.0-rc.17 ## 10/07/2020 diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php index 969845aa0..3646123bc 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php @@ -391,7 +391,7 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa $list = $new_list; // Apply manual ordering to the list. - asort($list); + asort($list, SORT_NUMERIC); } if ($order_dir !== 'asc') { diff --git a/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php b/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php index b20b575c1..bcb0533da 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php +++ b/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php @@ -563,8 +563,8 @@ class PageStorage extends FolderStorage $rawRoute = trim(preg_replace(PageIndex::PAGE_ROUTE_REGEX, '/', "/{$key}") ?? '', '/'); $route = PageIndex::normalizeRoute($rawRoute); - ksort($markdown, SORT_NATURAL); - ksort($children, SORT_NATURAL); + ksort($markdown, SORT_NATURAL | SORT_FLAG_CASE); + ksort($children, SORT_NATURAL | SORT_FLAG_CASE); $file = array_key_first($markdown[''] ?? (reset($markdown) ?: [])); @@ -628,7 +628,7 @@ class PageStorage extends FolderStorage $list[$storage_key] = $meta; } while ($queue); - ksort($list, SORT_NATURAL); + ksort($list, SORT_NATURAL | SORT_FLAG_CASE); // Update parent timestamps. foreach (array_reverse($list) as $storage_key => $meta) { diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 65a2a3ff0..bab0ccaec 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -1983,7 +1983,7 @@ class Pages $list = $new_list; // Apply manual ordering to the list. - asort($list); + asort($list, SORT_NUMERIC); } foreach ($list as $key => $sort) {