Ticket #38268: 38268.patch
File 38268.patch, 14.1 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-comment-query.php
diff --git src/wp-includes/class-wp-comment-query.php src/wp-includes/class-wp-comment-query.php index 67dfcae..ef8b6d5 100644
class WP_Comment_Query { 183 183 * See WP_Meta_Query. Default empty. 184 184 * @type int $number Maximum number of comments to retrieve. 185 185 * Default empty (no limit). 186 * @type int $paged When used with number, defines the page of results to return.187 * Default 1.188 186 * @type int $offset Number of comments to offset the query. Used to build 189 187 * LIMIT clause. Default 0. 190 188 * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. … … class WP_Comment_Query { 278 276 'no_found_rows' => true, 279 277 'orderby' => '', 280 278 'order' => 'DESC', 281 'paged' => '1',282 279 'parent' => '', 283 280 'parent__in' => '', 284 281 'parent__not_in' => '', … … class WP_Comment_Query { 643 640 644 641 $number = absint( $this->query_vars['number'] ); 645 642 $offset = absint( $this->query_vars['offset'] ); 646 $paged = absint( $this->query_vars['paged'] );647 643 648 644 if ( ! empty( $number ) ) { 649 645 if ( $offset ) { 650 646 $limits = 'LIMIT ' . $offset . ',' . $number; 651 647 } else { 652 $limits = 'LIMIT ' . ( $number * ( $paged - 1 ) ) . ',' .$number;648 $limits = 'LIMIT ' . $number; 653 649 } 654 650 } 655 651 -
src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
diff --git src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php index 8bffb0e..802d67e 100644
class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { 604 604 } 605 605 606 606 // Ensure nav menu item URL is set according to linked object. 607 if ( ! empty( $post->object_id ) ) { 608 if ( 'post_type' === $post->type ) { 609 $post->url = get_permalink( $post->object_id ); 610 } elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) { 611 $post->url = get_post_type_archive_link( $post->object ); 612 } elseif ( 'taxonomy' == $post->type && ! empty( $post->object ) ) { 613 $post->url = get_term_link( (int) $post->object, $post->object ); 614 } 607 if ( 'post_type' === $post->type && ! empty( $post->object_id ) ) { 608 $post->url = get_permalink( $post->object_id ); 609 } elseif ( 'taxonomy' === $post->type && ! empty( $post->object ) && ! empty( $post->object_id ) ) { 610 $post->url = get_term_link( (int) $post->object_id, $post->object ); 611 } elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) { 612 $post->url = get_post_type_archive_link( $post->object ); 613 } 614 if ( is_wp_error( $post->url ) ) { 615 $post->url = ''; 615 616 } 616 617 617 618 /** This filter is documented in wp-includes/nav-menu.php */ -
tests/phpunit/tests/auth.php
diff --git tests/phpunit/tests/auth.php tests/phpunit/tests/auth.php index 581e856..e025459 100644
class Tests_Auth extends WP_UnitTestCase { 239 239 240 240 // A valid key should be accepted 241 241 $check = check_password_reset_key( $key, $this->user->user_login ); 242 $this->assertNotWPError( $check ); 242 243 $this->assertInstanceOf( 'WP_User', $check ); 243 244 $this->assertSame( $this->user->ID, $check->ID ); 244 245 -
tests/phpunit/tests/comment/query.php
diff --git tests/phpunit/tests/comment/query.php tests/phpunit/tests/comment/query.php index beb8c43..ff4e3ac 100644
class Tests_Comment_Query extends WP_UnitTestCase { 1561 1561 $this->assertEquals( 2, $found ); 1562 1562 } 1563 1563 1564 /**1565 * @ticket 382681566 */1567 public function test_pagination_query() {1568 $comments = self::factory()->comment->create_many( 4, array(1569 'comment_post_ID' => self::$post_id,1570 ) );1571 1572 $query1 = new WP_Comment_Query();1573 $found1 = $query1->query( array(1574 'paged' => 2,1575 'number' => 21576 ) );1577 1578 $query2 = new WP_Comment_Query();1579 $found2 = $query2->query(1580 array(1581 'offset' => 2,1582 'number' => 21583 )1584 );1585 $this->assertEqualSets( $found1, $found2 );1586 }1587 1588 /**1589 * @ticket 382681590 */1591 public function test_pagination_offset_conflict() {1592 $comments = self::factory()->comment->create_many( 4, array(1593 'comment_post_ID' => self::$post_id,1594 ) );1595 $query1 = new WP_Comment_Query();1596 $found1 = $query1->query( array(1597 'paged' => 2,1598 'offset' => 1,1599 'number' => 21600 ) );1601 1602 $query2 = new WP_Comment_Query();1603 $found2 = $query2->query(1604 array(1605 'offset' => 1,1606 'number' => 21607 )1608 );1609 $this->assertEqualSets( $found1, $found2 );1610 }1611 1612 1564 public function test_post_type_single_value() { 1613 1565 register_post_type( 'post-type-1' ); 1614 1566 register_post_type( 'post-type-2' ); -
tests/phpunit/tests/customize/nav-menu-item-setting.php
diff --git tests/phpunit/tests/customize/nav-menu-item-setting.php tests/phpunit/tests/customize/nav-menu-item-setting.php index ebb9748..45aefb9 100644
class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { 834 834 } 835 835 836 836 /** 837 * Test WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() to set url for posts, terms, and post type archives. 838 * 839 * @ticket 38945 840 * @covers WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() 841 */ 842 function test_value_as_wp_post_nav_menu_item_term_urls() { 843 $term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) ); 844 register_post_type( 'press_release', array( 845 'has_archive' => true, 846 ) ); 847 $post_id = self::factory()->post->create( array( 'post_type' => 'press_release' ) ); 848 849 // Term. 850 $setting = new WP_Customize_Nav_Menu_Item_Setting( 851 $this->wp_customize, 852 'nav_menu_item[-1]' 853 ); 854 $this->wp_customize->set_post_value( $setting->id, array( 855 'type' => 'taxonomy', 856 'object' => 'category', 857 'object_id' => $term_id, 858 'title' => 'Category', 859 'url' => '', 860 ) ); 861 $setting->preview(); 862 $nav_menu_item = $setting->value_as_wp_post_nav_menu_item(); 863 $this->assertEquals( get_term_link( $term_id ), $nav_menu_item->url ); 864 865 // Post. 866 $setting = new WP_Customize_Nav_Menu_Item_Setting( 867 $this->wp_customize, 868 'nav_menu_item[-2]' 869 ); 870 $this->wp_customize->set_post_value( $setting->id, array( 871 'type' => 'post_type', 872 'object' => 'press_release', 873 'object_id' => $post_id, 874 'title' => 'PR', 875 'url' => '', 876 ) ); 877 $setting->preview(); 878 $nav_menu_item = $setting->value_as_wp_post_nav_menu_item(); 879 $this->assertEquals( get_permalink( $post_id ), $nav_menu_item->url ); 880 881 // Post type archive. 882 $setting = new WP_Customize_Nav_Menu_Item_Setting( 883 $this->wp_customize, 884 'nav_menu_item[-3]' 885 ); 886 $this->wp_customize->set_post_value( $setting->id, array( 887 'type' => 'post_type_archive', 888 'object' => 'press_release', 889 'title' => 'PR', 890 'url' => '', 891 ) ); 892 $setting->preview(); 893 $nav_menu_item = $setting->value_as_wp_post_nav_menu_item(); 894 $this->assertEquals( get_post_type_archive_link( 'press_release' ), $nav_menu_item->url ); 895 } 896 897 /** 837 898 * Test WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() where title is empty. 838 899 * 839 900 * @ticket 38015 -
tests/phpunit/tests/post/listPages.php
diff --git tests/phpunit/tests/post/listPages.php tests/phpunit/tests/post/listPages.php index d214631..a550c38 100644
3 3 class Tests_List_Pages extends WP_UnitTestCase { 4 4 var $pages; 5 5 6 protected $time = null; 7 6 8 /* 7 9 $defaults = array( 8 10 'depth' => 0, … … class Tests_List_Pages extends WP_UnitTestCase { 27 29 parent::setUp(); 28 30 global $wpdb; 29 31 $wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' ); 32 $this->time = time(); 33 $post_date = date( 'Y-m-d H:i:s', $this->time ); 30 34 $pages = array(); 31 35 self::factory()->user->create(); 32 $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) );33 $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) );34 $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) );36 $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1', 'post_date' => $post_date ) ); 37 $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2', 'post_date' => $post_date ) ); 38 $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2', 'post_date' => $post_date ) ); 35 39 36 40 foreach ( $pages as $page ) { 37 $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) );38 $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) );39 $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) );41 $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1', 'post_date' => $post_date ) ); 42 $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2', 'post_date' => $post_date ) ); 43 $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3', 'post_date' => $post_date ) ); 40 44 } 41 45 } 42 46 … … class Tests_List_Pages extends WP_UnitTestCase { 89 93 'depth' => 1, 90 94 'show_date' => true 91 95 ); 92 $expected['show_date'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a> ' . date( 'F j, Y' ) . '</li> 93 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . date( 'F j, Y' ) . '</li> 94 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . date( 'F j, Y' ) . '</li> 96 $date = date( get_option( 'date_format' ), $this->time ); 97 $expected['show_date'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a> ' . $date . '</li> 98 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . $date . '</li> 99 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . $date . '</li> 95 100 </ul></li>'; 96 101 $actual = wp_list_pages( $args ); 97 102 $this->AssertEquals( $expected['show_date'], $actual ); … … class Tests_List_Pages extends WP_UnitTestCase { 103 108 'show_date' => true, 104 109 'date_format' => 'l, F j, Y' 105 110 ); 106 $expected['date_format'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a> ' . date( 'l, F j, Y' ) . ' 111 $date = date( $args['date_format'], $this->time ); 112 $expected['date_format'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a> ' . $date . ' 107 113 <ul class=\'children\'> 108 <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a> ' . date( 'l, F j, Y' ). '</li>109 <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a> ' . date( 'l, F j, Y' ). '</li>110 <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a> ' . date( 'l, F j, Y' ). '</li>114 <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a> ' . $date . '</li> 115 <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a> ' . $date . '</li> 116 <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a> ' . $date . '</li> 111 117 </ul> 112 118 </li> 113 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . date( 'l, F j, Y' ). '119 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . $date . ' 114 120 <ul class=\'children\'> 115 <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a> ' . date( 'l, F j, Y' ). '</li>116 <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a> ' . date( 'l, F j, Y' ). '</li>117 <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a> ' . date( 'l, F j, Y' ). '</li>121 <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a> ' . $date . '</li> 122 <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a> ' . $date . '</li> 123 <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a> ' . $date . '</li> 118 124 </ul> 119 125 </li> 120 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . date( 'l, F j, Y' ). '126 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . $date . ' 121 127 <ul class=\'children\'> 122 <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a> ' . date( 'l, F j, Y' ). '</li>123 <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a> ' . date( 'l, F j, Y' ). '</li>124 <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a> ' . date( 'l, F j, Y' ). '</li>128 <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a> ' . $date . '</li> 129 <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a> ' . $date . '</li> 130 <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a> ' . $date . '</li> 125 131 </ul> 126 132 </li> 127 133 </ul></li>';