mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user