diff --git src/wp-includes/ms-deprecated.php src/wp-includes/ms-deprecated.php
index cd35f55..8ef3607 100644
|
|
function wp_get_sites( $args = array() ) { |
497 | 497 | if( is_numeric( $args['limit'] ) ){ |
498 | 498 | $args['number'] = $args['limit']; |
499 | 499 | $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; |
500 | 505 | } |
501 | 506 | |
502 | 507 | // Make sure count is disabled. |
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 { |
18 | 18 | 'wp.org/oof/' => array( 'domain' => 'wp.org', 'path' => '/oof/' ), |
19 | 19 | ); |
20 | 20 | |
| 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 | |
21 | 26 | foreach ( self::$site_ids as &$id ) { |
22 | 27 | $id = $factory->blog->create( $id ); |
23 | 28 | } |
… |
… |
class Tests_Multisite_WP_Get_Sites extends WP_UnitTestCase { |
59 | 64 | } |
60 | 65 | |
61 | 66 | /** |
| 67 | * @ticket 36566 |
| 68 | * @ticket 39879 |
| 69 | * |
62 | 70 | * @expectedDeprecated wp_get_sites |
63 | 71 | * @dataProvider data_wp_get_sites |
64 | 72 | * |
… |
… |
class Tests_Multisite_WP_Get_Sites extends WP_UnitTestCase { |
77 | 85 | return array( |
78 | 86 | array( 3, array(), 'Default arguments should return all sites from the current network.' ), |
79 | 87 | 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.' ), |
81 | 89 | array( 2, array( 'network_id' => 2 ), 'Only sites on a specified network ID should be returned.' ), |
82 | 90 | 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.' ), |
84 | 92 | array( 2, array( 'public' => 0, 'network_id' => null ), 'Non public sites on all networks.' ), |
85 | 93 | array( 2, array( 'public' => 1, 'network_id' => 1 ), 'Public sites on a single network.' ), |
86 | 94 | array( 1, array( 'public' => 1, 'network_id' => 2 ), 'Public sites on a second network.' ), |