-
Notifications
You must be signed in to change notification settings - Fork 273
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/404 error if requested path doesn't exist #331
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm the 404 appears as expected when no index.php
is present:
My index.php
is rendered as expected when it exists.
Let's wait until #339 lands, then merge trunk so we can add some integration tests for this scenario (covering https://github.com/WordPress/wordpress-playground/pull/331/files#r1192930303 too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's figure out the async function discussion before merging.
- Fix testing for current tests for Asyncify error (always passing before) - Add a test to handle no promise cases
Let's split this into two PRs: one that deals with promises in |
We're almost there, btw. The implementation is sound and the two suggestions I left will take the tests where they need to be. Also note the typecheck CI job failed with:
This SO question should help: https://stackoverflow.com/questions/64452484/how-can-i-safely-access-caught-error-properties-in-typescript |
<!-- Thanks for contributing to WordPress Playground! --> ## What? <!-- In a few words, what is the PR actually doing? Include screenshots or screencasts if applicable --> We decided to split #331 into two parts, to make changes clear. Part 1 of #331 Part 2 is #388 This pr simplifies the logic of `#handleRequest` method by removing unnecessary async wrapping ## Why? It was originally introduced in #331, where a 404 page for nonexisting files was introduced, in order to simplify things. For more info, look at #331 <!-- Why is this PR necessary? What problem is it solving? Reference any existing previous issue(s) or PR(s), but please add a short summary here, too --> ## How? - By removing the `async` function. `async` functions return a promise by themselves and also `resolve` method is able to resolve nested promises if they returned correctly. So the original `async` function wasn't really necessary <!-- How is your PR addressing the issue at hand? What are the implementation details? --> ## Testing Instructions N/A
<!-- Thanks for contributing to WordPress Playground! --> ## What? This pr adds a 404 error if the requested path doesn't exist <!-- In a few words, what is the PR actually doing? Include screenshots or screencasts if applicable --> We decided to split #331 into two parts, to make changes clear. Part 2 of #331 Part 1 is #387 ## Why? When the user uses a path that doesn't have any files, the `wp-now` was throwing an error, and was no longer usable. This pr fixes that. Also, take a look at #331 <!-- Why is this PR necessary? What problem is it solving? Reference any existing previous issue(s) or PR(s), but please add a short summary here, too --> ## How? When we call `php.run` method, we build the `scriptPath` using `resolvePHPFilePath`. If the file is not there we assume that an `/index.php` file exists in the folder. This is not correct, and we need to return a 404 `PhpRequest`. Also, take a look at #331 <!-- How is your PR addressing the issue at hand? What are the implementation details? --> ## Testing Instructions - Create an empty folder - Run wp-now and make sure you add this folder as a path: npx nx preview wp-now start --path=<your-empty-folder> - Ensure that you don't see any errors in the console - Ensure that you see 404 File not found in the browser - Change the URL to something else. eg: /file-not-exist.php. - Ensure that you still see 404 File not found
<!-- Thanks for contributing to WordPress Playground! --> ## What? <!-- In a few words, what is the PR actually doing? Include screenshots or screencasts if applicable --> We decided to split #331 into two parts, to make changes clear. Part 1 of WordPress/wordpress-playground#331 Part 2 is WordPress/wordpress-playground#388 This pr simplifies the logic of `#handleRequest` method by removing unnecessary async wrapping ## Why? It was originally introduced in #331, where a 404 page for nonexisting files was introduced, in order to simplify things. For more info, look at #331 <!-- Why is this PR necessary? What problem is it solving? Reference any existing previous issue(s) or PR(s), but please add a short summary here, too --> ## How? - By removing the `async` function. `async` functions return a promise by themselves and also `resolve` method is able to resolve nested promises if they returned correctly. So the original `async` function wasn't really necessary <!-- How is your PR addressing the issue at hand? What are the implementation details? --> ## Testing Instructions N/A
<!-- Thanks for contributing to WordPress Playground! --> ## What? This pr adds a 404 error if the requested path doesn't exist <!-- In a few words, what is the PR actually doing? Include screenshots or screencasts if applicable --> We decided to split #331 into two parts, to make changes clear. Part 2 of WordPress/wordpress-playground#331 Part 1 is WordPress/wordpress-playground#387 ## Why? When the user uses a path that doesn't have any files, the `wp-now` was throwing an error, and was no longer usable. This pr fixes that. Also, take a look at #331 <!-- Why is this PR necessary? What problem is it solving? Reference any existing previous issue(s) or PR(s), but please add a short summary here, too --> ## How? When we call `php.run` method, we build the `scriptPath` using `resolvePHPFilePath`. If the file is not there we assume that an `/index.php` file exists in the folder. This is not correct, and we need to return a 404 `PhpRequest`. Also, take a look at #331 <!-- How is your PR addressing the issue at hand? What are the implementation details? --> ## Testing Instructions - Create an empty folder - Run wp-now and make sure you add this folder as a path: npx nx preview wp-now start --path=<your-empty-folder> - Ensure that you don't see any errors in the console - Ensure that you see 404 File not found in the browser - Change the URL to something else. eg: /file-not-exist.php. - Ensure that you still see 404 File not found
Resolves: #304
This pr adds a 404 error if the requested path doesn't exist
Testing instructions
wp-now
and make sure you add this folder as apath
:npx nx preview wp-now start --path=<your-empty-folder>
404 File not found
in the browser/file-not-exist.php
.404 File not found