Changeset 25280
- Timestamp:
- 09/06/2013 04:35:22 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r24594 r25280 100 100 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); 101 101 } 102 } 103 104 if ( get_query_var( 'day' ) && get_query_var( 'monthnum' ) && get_query_var( 'year' ) ) { 105 $year = get_query_var( 'year' ); 106 $month = get_query_var( 'monthnum' ); 107 $day = get_query_var( 'day' ); 108 $date = sprintf( '%04d-%02d-%02d', $year, $month, $day ); 109 if ( ! wp_checkdate( $month, $day, $year, $date ) ) { 110 $redirect_url = get_month_link( $year, $month ); 111 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum', 'day' ), $redirect_url ); 112 } 113 } elseif ( get_query_var( 'monthnum' ) && get_query_var( 'year' ) && 12 < get_query_var( 'monthnum' ) ) { 114 $redirect_url = get_year_link( get_query_var( 'year' ) ); 115 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum' ), $redirect_url ); 102 116 } 103 117 -
trunk/src/wp-includes/query.php
r25269 r25280 1514 1514 if ( $qv['day'] ) { 1515 1515 if ( ! $this->is_date ) { 1516 $this->is_day = true; 1517 $this->is_date = true; 1516 $date = sprintf( '%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day'] ); 1517 if ( $qv['monthnum'] && $qv['year'] && ! wp_checkdate( $qv['monthnum'], $qv['day'], $qv['year'], $date ) ) { 1518 $qv['error'] = '404'; 1519 } else { 1520 $this->is_day = true; 1521 $this->is_date = true; 1522 } 1518 1523 } 1519 1524 } … … 1521 1526 if ( $qv['monthnum'] ) { 1522 1527 if ( ! $this->is_date ) { 1523 $this->is_month = true; 1524 $this->is_date = true; 1528 if ( 12 < $qv['monthnum'] ) { 1529 $qv['error'] = '404'; 1530 } else { 1531 $this->is_month = true; 1532 $this->is_date = true; 1533 } 1525 1534 } 1526 1535 } -
trunk/tests/phpunit/tests/canonical.php
r25002 r25280 240 240 array( '/?year=2008', '/2008/'), 241 241 242 array( '/2012/13/', '/2012/'), 243 array( '/2012/11/51/', '/2012/11/'), 244 242 245 // Authors 243 246 array( '/?author=%d', '/author/canonical-author/' ), -
trunk/tests/phpunit/tests/query/conditionals.php
r25002 r25280 630 630 // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 631 631 // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 632 633 function test_bad_dates() { 634 $this->go_to( '/2013/13/13/' ); 635 $this->assertQueryTrue( 'is_404' ); 636 637 $this->go_to( '/2013/11/41/' ); 638 $this->assertQueryTrue( 'is_404' ); 639 } 632 640 } -
trunk/tests/phpunit/tests/query/results.php
r25248 r25280 487 487 $this->assertEqualSets( array( $author_1 ), $author_ids ); 488 488 } 489 490 /** 491 * @ticket 10935 492 */ 493 function test_query_is_date() { 494 $this->q->query( array( 495 'year' => '2007', 496 'monthnum' => '01', 497 'day' => '01', 498 ) ); 499 500 $this->assertTrue( $this->q->is_date ); 501 $this->assertTrue( $this->q->is_day ); 502 $this->assertFalse( $this->q->is_month ); 503 $this->assertFalse( $this->q->is_year ); 504 505 $this->q->query( array( 506 'year' => '2007', 507 'monthnum' => '01', 508 ) ); 509 510 $this->assertTrue( $this->q->is_date ); 511 $this->assertFalse( $this->q->is_day ); 512 $this->assertTrue( $this->q->is_month ); 513 $this->assertFalse( $this->q->is_year ); 514 515 $this->q->query( array( 516 'year' => '2007', 517 ) ); 518 519 $this->assertTrue( $this->q->is_date ); 520 $this->assertFalse( $this->q->is_day ); 521 $this->assertFalse( $this->q->is_month ); 522 $this->assertTrue( $this->q->is_year ); 523 524 $this->q->query( array( 525 'year' => '2007', 526 'monthnum' => '01', 527 'day' => '50', 528 ) ); 529 530 $this->assertTrue( $this->q->is_404 ); 531 $this->assertFalse( $this->q->is_date ); 532 $this->assertFalse( $this->q->is_day ); 533 $this->assertFalse( $this->q->is_month ); 534 $this->assertFalse( $this->q->is_year ); 535 } 489 536 }
Note: See TracChangeset
for help on using the changeset viewer.