Opened 9 years ago
Last modified 3 weeks ago
#37832 reopened defect (bug)
Using ?p=xxx on a posts page with an invalid post ID does not return a 404 status
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Canonical | Keywords: | |
| Focuses: | Cc: |
Description
Steps to replicate:
- Create a page and set it as the posts page.
- Visit this page with ?p=123456 (an invalid ID) added.
WordPress will return whatever 'no results found' message you have in the theme, but with a 200 status.
The handle_404 function seems to have been set up to always give a 200 status if is_home() returns true. This should not apply if you're overriding the query in some way via the URL.
Somehow many of these URLs have been detected by Google on a site of ours and are being reported as soft 404s. How they were found is one thing, but WordPress should not be returning a 200 status regardless.
Change History (7)
This ticket was mentioned in Slack in #core by sirlouen. View the logs.
3 weeks ago
#6
@
3 weeks ago
- Component changed from Posts, Post Types to Canonical
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Reproduction Report
Description
⚠️ This report can't completely validate that the issue is happening
Environment
- WordPress: 6.9-beta2-61080
- PHP: 8.2.29
- Server: nginx/1.29.3
- Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
- Browser: Chrome 141.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.3
- MU Plugins:
- WooCommerce Analytics - Proxy Speed Module 1.0.0
- Plugins:
- Test Reports 1.2.0
Testing Instructions
- First, I'm assuming that we have the permalinks set to anything other than the
plainformat, as it returns404as expected
- ❓ With any other permalink structure, inside the blog page, any query is considered a search and an invalid search returns a
200withSorry, but nothing was found. Please try a search with different keywords.message as expected
Actual Results
- ❌ Error condition is not occurring
Additional Notes
If we do:
/test-page/?author=1
Being test-page, it will return all posts by this author
Similarly if we do
/new-page/?author=2
Again it will return the Sorry, but nothing was found. Please try a search with different keywords. as this has not been found
Doing this query, in any other post, not associated to the blog pattern, will return the canonical post as expected.
Conclusion: Everything is working as expected. Closing this as worksforme
#7
@
3 weeks ago
- Resolution worksforme deleted
- Status changed from closed to reopened
9 years later, finally a response, and you don't even follow the instructions :(
I still replicate the behavior exactly as is:
- create a Page, and set it as the posts page
- visit this page, appending ?p=123456 to the end of the URL, to see a 200 response.
I don't know why in the testing instructions you changed this to append the author parameter instead.
Related: #7592, #22798, #22879, #23060.