Skip to content

Commit

Permalink
Fix #1184 Fix issue with using a multiple taxonomy filter of which on…
Browse files Browse the repository at this point in the history
…e had no results

If there are 2+ taxonomies required but one has 0 items, it was just
picking the ones corresponding to the other taxonomy, thus generating a
wrong result. Adding an empty array will later make array_intersect_key
generate an empty array if the operation is `and`
  • Loading branch information
flaviocopes committed Dec 3, 2016
1 parent 678c445 commit 896fb81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Synced `webserver-configs/htaccess.txt` with `.htaccess`
1. [](#bugfix)
* Fix page collections problem with `@page.modular` [#1178](https://github.com/getgrav/grav/pull/1178)
* Fix issue with using a multiple taxonomy filter of which one had no results [#1184](https://github.com/getgrav/grav/issues/1184)

# v1.1.9-rc.2
## 11/26/2016
Expand Down
4 changes: 3 additions & 1 deletion system/src/Grav/Common/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public function findTaxonomy($taxonomies, $operator = 'and')
foreach ((array)$items as $item) {
if (isset($this->taxonomy_map[$taxonomy][$item])) {
$matches[] = $this->taxonomy_map[$taxonomy][$item];
} else {
$matches[] = [];
}
}
}
Expand Down Expand Up @@ -126,7 +128,7 @@ public function taxonomy($var = null)

return $this->taxonomy_map;
}

/**
* Gets item keys per taxonomy
*
Expand Down

3 comments on commit 896fb81

@hughbris
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hoped you'd offer me the pull request before you did it :(

@flaviocopes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @hughbris, I had it ready since I was testing it, figured it was quicker than asking you to make a PR. Didn't think you were willing to make a PR, will edit the changelog message to thank you, if this helps!

@flaviocopes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to juggle a lot of testing and checking possible issues, the quicker the fix gets in, the better, before it's forgotten or I have to look again in the future and take the time replicate the problem, did not mean to harm your contribution :)

Please sign in to comment.