Changeset 34697
- Timestamp:
- 09/29/2015 07:36:16 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r34690 r34697 3124 3124 $page = 1; 3125 3125 3126 if ( empty($q['offset']) ) { 3126 // If 'offset' is provided, it takes precedence over 'paged'. 3127 if ( isset( $q['offset'] ) && is_numeric( $q['offset'] ) ) { 3128 $q['offset'] = absint( $q['offset'] ); 3129 $pgstrt = $q['offset'] . ', '; 3130 } else { 3127 3131 $pgstrt = absint( ( $page - 1 ) * $q['posts_per_page'] ) . ', '; 3128 } else { // we're ignoring $page and using 'offset'3129 $q['offset'] = absint($q['offset']);3130 $pgstrt = $q['offset'] . ', ';3131 3132 } 3132 3133 $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; -
trunk/tests/phpunit/tests/query.php
r34073 r34697 460 460 $post = get_queried_object(); 461 461 } 462 463 /** 464 * @ticket 34060 465 */ 466 public function test_offset_0_should_override_page() { 467 $q = new WP_Query( array( 468 'paged' => 2, 469 'posts_per_page' => 5, 470 'offset' => 0, 471 ) ); 472 473 $this->assertContains( 'LIMIT 0, 5', $q->request ); 474 } 475 476 /** 477 * @ticket 34060 478 */ 479 public function test_offset_should_be_ignored_when_not_set() { 480 $q = new WP_Query( array( 481 'paged' => 2, 482 'posts_per_page' => 5, 483 ) ); 484 485 $this->assertContains( 'LIMIT 5, 5', $q->request ); 486 } 487 488 /** 489 * @ticket 34060 490 */ 491 public function test_offset_should_be_ignored_when_passed_a_non_numeric_value() { 492 $q = new WP_Query( array( 493 'paged' => 2, 494 'posts_per_page' => 5, 495 'offset' => '', 496 ) ); 497 498 $this->assertContains( 'LIMIT 5, 5', $q->request ); 499 } 462 500 }
Note: See TracChangeset
for help on using the changeset viewer.