#5490 closed defect (bug) (worksforme)
Bad post URL gives database error instead of 404
| Reported by: | Bobcat | Owned by: | westi |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 2.5 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
If I enter a URL such as http://www.example.com/blog/2007/12/unknown/ where there is no such post, I expect to get a 404 error. Instead, I get the following database error:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY p.post_date ASC LIMIT 1' at line 1]
SELECT p.ID, p.post_title FROM wp_posts AS p WHERE p.post_date > '' AND p.post_type = 'post' AND p.post_status = 'publish' AND p.ID != ORDER BY p.post_date ASC LIMIT 1
Change History (11)
#3
@
19 years ago
After doing some more research, I think my problem is that the _wp_old_slug redirect doesn't work. I see the old slug in the post_meta table, but the redirect doesn't happen.
#4
@
19 years ago
It looks like the wp_old_slug_redirect redirect isn't happening because it's not being classified as a 404. And it's not a 404 because $wp_query->posts is not empty even though the post doesn't exist. $wp_query->posts has one element with only comment_status and ping_status, nothing else; there's no real post there.
#7
@
18 years ago
I just retested this with 2.5. I get a page with an empty post; HTTP response is '200'. Still not the '404' response I expected, which would allow an error message to be displayed to the user.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
This is a duplicate of another ticket.