Ticket #5490 (assigned defect)

Opened 10 months ago

Last modified 4 months ago

Bad post URL gives database error instead of 404

Reported by: Bobcat Assigned to: westi (accepted)
Priority: normal Milestone: 2.9
Component: General Version: 2.5
Severity: normal Keywords:
Cc:

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

12/19/07 19:10:34 changed by santosj

This is a duplicate of another ticket.

12/19/07 19:10:50 changed by santosj

Need ticket number before closing.

12/20/07 02:34:50 changed by Bobcat

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.

12/20/07 13:40:39 changed by Bobcat

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.

12/20/07 15:25:07 changed by westi

  • owner changed from anonymous to westi.
  • status changed from new to assigned.

02/09/08 02:23:02 changed by DD32

Doesnt appear to be a problem on trunk for me. (Just tested)

Related: #5185, #5471

03/30/08 00:45:26 changed by Bobcat

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.

03/31/08 16:29:18 changed by lloydbudd

  • version changed from 2.3.1 to 2.5.

06/25/08 20:36:31 changed by Scott H

Works for me on trunk.