Opened 16 years ago
Closed 16 years ago
#7230 closed defect (bug) (fixed)
The 0th of July
Reported by: | tellyworth | Owned by: | |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
It's possible to enter a post date with a zero on the write post page. WP doesn't validate the date, and unless MySQL is running in strict mode the invalid date will get stored in the post_date column.
Steps to reproduce:
- New Post
- Edit the timestamp
- Change the day field to "00"
- Publish
- Click the View Post link
Expected: WP should validate the date and change it to something that works.
Actual: the post is published but the permalink is 404 because of a quirk in the way get_permalink() handles the post_date field.
The steps to reproduce assume MySQL is not running in strict mode, I haven't tested that case. Reproduced in trunk, it probably affects all versions.
Attachments (2)
Change History (10)
#2
@
16 years ago
Quick fix. Year, month, or day <=0 are given the current year, month, or day instead.
#3
@
16 years ago
My take is in the new patch. It uses checkdate() to cover other invalid dates, and also fixes a minor bug in the time validation (e.g. hours > 48 wasn't handled correctly).
#4
@
16 years ago
If we use checkdate() we need to put it in a hook so that non-Gregorian calendars can be supported.
Just to clarify, the post_date field actually stores '2008-07-00' if you do this. It's a MySQL feature, believe it or not.