New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: return empty when filtering menuItems
by a location
with no assigned items
#3043
fix: return empty when filtering menuItems
by a location
with no assigned items
#3043
Conversation
Code Climate has analyzed commit 670b1bf and detected 0 issues on this pull request. View more on Code Climate. |
@justlevine I pulled this branch and querying for a list of menuItems when no menu has been assigned to a location still returns random menu items 🤔 |
@justlevine ah my bad. I was executing as an authenticated user who should see all menu items because they're not considered private. 🤦🏻♂️ |
If my fix worked correctly then even if the user is authenticated they should only receive the items they're actually filtering for, so it should still come back |
ok, ya, authenticated users still get the incorrect behavior then. |
@justlevine let me confirm that I didn't have anything else going on. . .like WPGraphQL Smart Cache object cache active or anything 👀 |
@justlevine oooh. . .so this was related to WPGraphQL Smart Cache, but not really related to caching. . . WPGraphQL Smart Cache declares WPGraphQL as a dev dependency and my local copy of WPGraphQL Smart Cache was overriding the checked out version of WPGraphQL I was testing 🤔 Interesting. My hunch is that we don't actually need WPGraphQL defined as a dev dependency for WPGraphQL Smart Cache. That's wild though that the dev dependency was taking precedent over the actual active WPGraphQL plugin 🤔 Anyway, by de-activating WPGraphQL Smart Cache I was able to experience the intended behavior of no nodes resolving when filtering menus by location when that location has no menu assigned yet (even for admin user) |
What does this implement/fix? Explain your changes.
This PR fixes an issue in the
MenuItemConnectionResolver
logic, where querying amenuItem
by alocation
with unset terms would return all menu items, instead of none.Logic has been changed so the
tax_query
args are given a'term_id' => []
.Tests have been added to cover:
location
with no menu items returns null.location
with no menu items returns null as an admin.location
with menu items, doesn't return items from a differentlocation
(either public or as an admin).Does this close any currently open issues?
Fixes #3029
Any relevant logs, error output, GraphiQL screenshots, etc?
Any other comments?
…
Where has this been tested?
Operating System: Ubuntu 20.04 (wsl2 + devilbox + php 8.1.14)
WordPress Version: 6.4.3