Make WordPress Core

Ticket #42261: 42261.1.diff

File 42261.1.diff, 1.9 KB (added by mauteri, 6 years ago)

Fix unit test

  • src/wp-includes/class-wp-query.php

     
    18061806                if ( ( isset( $q['posts_per_archive_page'] ) && $q['posts_per_archive_page'] != 0 ) && ( $this->is_archive || $this->is_search ) ) {
    18071807                        $q['posts_per_page'] = $q['posts_per_archive_page'];
    18081808                }
     1809                if ( $this->is_feed ) {
     1810                        // This overrides posts_per_page.
     1811                        if ( ! empty( $q['posts_per_rss'] ) ) {
     1812                                $q['posts_per_page'] = $q['posts_per_rss'];
     1813                        } else {
     1814                                $q['posts_per_page'] = get_option( 'posts_per_rss' );
     1815                        }
     1816                }
    18091817                if ( ! isset( $q['nopaging'] ) ) {
    18101818                        if ( $q['posts_per_page'] == -1 ) {
    18111819                                $q['nopaging'] = true;
     
    18141822                        }
    18151823                }
    18161824
    1817                 if ( $this->is_feed ) {
    1818                         // This overrides posts_per_page.
    1819                         if ( ! empty( $q['posts_per_rss'] ) ) {
    1820                                 $q['posts_per_page'] = $q['posts_per_rss'];
    1821                         } else {
    1822                                 $q['posts_per_page'] = get_option( 'posts_per_rss' );
    1823                         }
    1824                         $q['nopaging'] = false;
    1825                 }
    18261825                $q['posts_per_page'] = (int) $q['posts_per_page'];
    18271826                if ( $q['posts_per_page'] < -1 ) {
    18281827                        $q['posts_per_page'] = abs( $q['posts_per_page'] );
  • tests/phpunit/tests/query.php

     
    5757        }
    5858
    5959        /**
     60         * @ticket 42261
     61         */
     62        function test_rss_query_no_limit() {
     63                self::factory()->post->create_many( 15 );
     64
     65                // Programmatically set posts_per_rss to -1
     66                add_filter( 'option_posts_per_rss', array( $this, 'filter_option_posts_per_rss' ) );
     67
     68                $this->go_to( get_feed_link() );
     69
     70                global $wp_query;
     71
     72                $this->assertEquals( 15, count( $wp_query->posts ) );
     73        }
     74
     75        public function filter_option_posts_per_rss() {
     76                return -1;
     77        }
     78
     79        /**
    6080         * @ticket 26627
    6181         */
    6282        function test_tag_queried_object() {