Fixed behavior of opposite filters in Pages::getCollection() to match Grav 1.6 [#3216]

This commit is contained in:
Matias Griese
2021-02-10 10:58:17 +02:00
parent 45cea4fc4b
commit 8c00a0bc00
2 changed files with 14 additions and 3 deletions

View File

@@ -26,6 +26,7 @@
* Fixed pipelined asset using different hash when extra asset is added to before/after position [#2781](https://github.com/getgrav/grav/issues/2781)
* Fixed trailing slash redirect to only apply to GET/HEAD requests and use 301 status code [#3127](https://github.com/getgrav/grav/issues/3127)
* Fixed `<meta name="flattr:*" content="*">` to use name instead property [#3010](https://github.com/getgrav/grav/pull/3010)
* Fixed behavior of opposite filters in `Pages::getCollection()` to match Grav 1.6 [#3216](https://github.com/getgrav/grav/pull/3216)
# v1.7.5
## 02/01/2021

View File

@@ -459,14 +459,24 @@ class Pages
// Remove any inclusive sets from filter.
$sets = ['published', 'visible', 'modular', 'routable'];
foreach ($sets as $type) {
$var = "non-{$type}";
if (isset($filters[$type], $filters[$var]) && $filters[$type] && $filters[$var]) {
unset($filters[$type], $filters[$var]);
$nonType = "non-{$type}";
if (isset($filters[$type], $filters[$nonType]) && $filters[$type] === $filters[$nonType]) {
if (!$filters[$type]) {
// Both options are false, return empty collection as nothing can match the filters.
return new Collection();
}
// Both options are true, remove opposite filters as all pages will match the filters.
unset($filters[$type], $filters[$nonType]);
}
}
// Filter the collection
foreach ($filters as $type => $filter) {
if (null === $filter) {
continue;
}
// Convert non-type to type.
if (str_starts_with($type, 'non-')) {
$type = substr($type, 4);