Check bad dates and redirect, instead of 404ing, as necessary and appropriate.

Adds query, conditional, and canonical Unit Tests.

Props kovshenin, SergeyBiryukov, DrewAPicture.
Fixes #10935.



git-svn-id: https://develop.svn.wordpress.org/trunk@25280 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2013-09-06 16:35:22 +00:00
parent 69a949d160
commit 09b9c44de9
5 changed files with 85 additions and 4 deletions

View File

@@ -1513,15 +1513,24 @@ class WP_Query {
if ( $qv['day'] ) {
if ( ! $this->is_date ) {
$this->is_day = true;
$this->is_date = true;
$date = sprintf( '%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day'] );
if ( $qv['monthnum'] && $qv['year'] && ! wp_checkdate( $qv['monthnum'], $qv['day'], $qv['year'], $date ) ) {
$qv['error'] = '404';
} else {
$this->is_day = true;
$this->is_date = true;
}
}
}
if ( $qv['monthnum'] ) {
if ( ! $this->is_date ) {
$this->is_month = true;
$this->is_date = true;
if ( 12 < $qv['monthnum'] ) {
$qv['error'] = '404';
} else {
$this->is_month = true;
$this->is_date = true;
}
}
}