Fixed Flex ordering to be natural and case insensitive

This commit is contained in:
Matias Griese
2020-12-02 10:37:51 +02:00
parent f5d1e98491
commit 30401df4b7
5 changed files with 7 additions and 8 deletions

View File

@@ -44,6 +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)
# v1.7.0-rc.17
## 10/07/2020

View File

@@ -144,9 +144,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
$matching = array_filter($matching);
if ($matching) {
uksort($matching, static function ($a, $b) {
return -($a <=> $b);
});
arsort($matching, SORT_NUMERIC);
}
return $this->select(array_keys($matching));

View File

@@ -389,9 +389,9 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
// Order by current field.
if (strtoupper($ordering) === 'DESC') {
arsort($search, SORT_NATURAL);
arsort($search, SORT_NATURAL | SORT_FLAG_CASE);
} else {
asort($search, SORT_NATURAL);
asort($search, SORT_NATURAL | SORT_FLAG_CASE);
}
$previous = $search;
@@ -738,7 +738,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
}
// Sort the index before saving it.
ksort($index, SORT_NATURAL);
ksort($index, SORT_NATURAL | SORT_FLAG_CASE);
static::onChanges($index, $added, $updated, $removed);

View File

@@ -82,7 +82,7 @@ class FileStorage extends FolderStorage
$list[$key] = $this->getObjectMeta($key);
}
ksort($list, SORT_NATURAL);
ksort($list, SORT_NATURAL | SORT_FLAG_CASE);
return $list;
}

View File

@@ -553,7 +553,7 @@ class FolderStorage extends AbstractFilesystemStorage
$list = $this->buildIndexFromFilesystem($path);
}
ksort($list, SORT_NATURAL);
ksort($list, SORT_NATURAL | SORT_FLAG_CASE);
return $list;
}