Skip to content
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

Add: Support 404 page #388

Merged
merged 1 commit into from
May 18, 2023
Merged

Add: Support 404 page #388

merged 1 commit into from
May 18, 2023

Conversation

kozer
Copy link
Contributor

@kozer kozer commented May 18, 2023

What?

This pr adds a 404 error if the requested path doesn't exist

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

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

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=
  • 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 pushed a commit that referenced this pull request May 18, 2023
<!-- 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
@kozer kozer merged commit df871b8 into WordPress:trunk May 18, 2023
Pookie717 added a commit to Pookie717/wordpress-playground that referenced this pull request Oct 1, 2023
<!-- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants