-
Notifications
You must be signed in to change notification settings - Fork 272
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
Update: Simplify base-php sapi_handle_request call #387
Update: Simplify base-php sapi_handle_request call #387
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.
Because this PR is going in the commit history, it would be great to have a full pull request description for it.
<!-- 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
@danielbachhuber the commit message for this one wasn't quite there. I re-applied it with a small writeup to explain the entire context behind the change: I know I'm pushing hard on this one. This is the most important code path in the entire codebase and I want to make sure the change history is extremely clear for the next person debugging it. |
@adamziel Cool, sounds good. |
<!-- 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
What?
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 wrappingWhy?
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
How?
async
function.async
functions return a promise by themselves and alsoresolve
method is able to resolve nested promises if they returned correctly. So the originalasync
function wasn't really necessaryTesting Instructions
N/A