WordPress.org

Make WordPress Core

Ticket #39879: 39879.1.diff

File 39879.1.diff, 2.8 KB (added by iandunn, 2 years ago)
  • src/wp-includes/ms-deprecated.php

    diff --git src/wp-includes/ms-deprecated.php src/wp-includes/ms-deprecated.php
    index cd35f55..8ef3607 100644
    function wp_get_sites( $args = array() ) { 
    497497        if( is_numeric( $args['limit'] ) ){
    498498                $args['number'] = $args['limit'];
    499499                $args['limit'] = null;
     500        } elseif ( isset( $args['limit'] ) && false === $args['limit'] ) {
     501                // get_sites() doesn't have a corresponding value to allow fetching
     502                // unlimited sites, but PHP_INT_MAX serves the same purpose in practice
     503                $args['number'] = PHP_INT_MAX;
     504                $args['limit']  = null;
    500505        }
    501506
    502507        // Make sure count is disabled.
  • tests/phpunit/tests/multisite/wpGetSites.php

    diff --git tests/phpunit/tests/multisite/wpGetSites.php tests/phpunit/tests/multisite/wpGetSites.php
    index f15c073..8e852ef 100644
    class Tests_Multisite_WP_Get_Sites extends WP_UnitTestCase { 
    1818                        'wp.org/oof/' => array( 'domain' => 'wp.org', 'path' => '/oof/' ),
    1919                );
    2020
     21                // We need more than 100 sites to test the `limit` parameter (see #39879)
     22                for ( $i = 0; $i < 101; $i++ ) {
     23                        self::$site_ids["wp.org/foo$i"] = array( 'domain' => 'wp.org', 'path' => "/foo$i/", 'site_id' => 3 );
     24                }
     25
    2126                foreach ( self::$site_ids as &$id ) {
    2227                        $id = $factory->blog->create( $id );
    2328                }
    class Tests_Multisite_WP_Get_Sites extends WP_UnitTestCase { 
    5964        }
    6065
    6166        /**
     67         * @ticket 36566
     68         * @ticket 39879
     69         *
    6270         * @expectedDeprecated wp_get_sites
    6371         * @dataProvider data_wp_get_sites
    6472         *
    class Tests_Multisite_WP_Get_Sites extends WP_UnitTestCase { 
    7785                return array(
    7886                        array( 3, array(), 'Default arguments should return all sites from the current network.' ),
    7987                        array( 0, array( 'network_id' => 999 ), 'No sites should match a query with an invalid network ID.' ),
    80                         array( 5, array( 'network_id' => null ), 'A network ID of null should return all sites on all networks.' ),
     88                        array( 106, array( 'network_id' => null, 'limit' => false ), 'A network ID of null should return all sites on all networks.' ),
    8189                        array( 2, array( 'network_id' => 2 ), 'Only sites on a specified network ID should be returned.' ),
    8290                        array( 5, array( 'network_id' => array( 1, 2 ) ), 'If multiple network IDs are specified, sites from both should be returned.' ),
    83                         array( 3, array( 'public' => 1, 'network_id' => null ), 'Public sites on all networks.' ),
     91                        array( 104, array( 'public' => 1, 'network_id' => null, 'limit' => false ), 'Public sites on all networks.' ),
    8492                        array( 2, array( 'public' => 0, 'network_id' => null ), 'Non public sites on all networks.' ),
    8593                        array( 2, array( 'public' => 1, 'network_id' => 1 ), 'Public sites on a single network.' ),
    8694                        array( 1, array( 'public' => 1, 'network_id' => 2 ), 'Public sites on a second network.' ),