-
Notifications
You must be signed in to change notification settings - Fork 441
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: handle 404s in NodeResolver.php #2752
Merged
jasonbahl
merged 6 commits into
wp-graphql:develop
from
justlevine:fix/handle-404s-in-node-resolver
Mar 8, 2023
Merged
fix: handle 404s in NodeResolver.php #2752
jasonbahl
merged 6 commits into
wp-graphql:develop
from
justlevine:fix/handle-404s-in-node-resolver
Mar 8, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4e5b4dc
to
c443643
Compare
c443643
to
162a569
Compare
…hen tries to query a node by an invalid uri
This was referenced Mar 8, 2023
…t-resolving-properly test: add tests for wp-graphql#2751 / wp-graphql#2752 (pr to wp-graphql#2752 branch)
Code Climate has analyzed commit f7315e1 and detected 0 issues on this pull request. View more on Code Climate. |
jasonbahl
approved these changes
Mar 8, 2023
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes.
This PR fixes a bug where
NodeResolver::resolve_uri()
falls back to the home page when trying to resolve a non-existent URI.This issue is due to our refactor of
resolve_uri()
to useWP_Query
(#2680), which didnt take into account that our existingparse_request()
shim deviated fromWP::parse_request()
.With the PR,
parse_request()
now correctly sets the$query_vars['error']
value in line with WP core. Additionally, queries directly to the home page ('/'
), are resolved early. This increases performance, but more importantly addresses the fact that most WP sites dont have an explicit redirect rule for the home page (which causes$query_vars['error']
to be set for those requests as well.To Test.
/posts/%postname%/
.Does this close any currently open issues?
Fixes #2751
Any relevant logs, error output, GraphiQL screenshots, etc?
(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
![image](https://user-images.githubusercontent.com/29322304/223422965-a4dabe3e-086e-4e4d-b788-e970fb245c8b.png)
Any other comments?
$this->wp
can become stale when there are multiplenodeByUri
queries in the same request. I cannot replicate that bug consistently enough to address it, it preexists nodeByUri resolving incorrectly when permalinks are set to a custom structure #2751, and does not interfere with this fix, so I don't believe it should be considered a blocker for either this PR or v1.14.0.Where has this been tested?
Operating System: Ubuntu 20.04 (wsl2 + devilbox + php 8.0.26)
WordPress Version: 6.1.1