WordPress.org

Make WordPress Core

Changeset 38102


Ignore:
Timestamp:
07/19/2016 01:09:39 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Multisite: Correct default value for orderby in WP_Network_Query::__construct().

Add a unit test.

See #32504.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-network-query.php

    r38003 r38102  
    109109     *     @type bool         $no_found_rows        Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
    110110     *     @type string|array $orderby              Network status or array of statuses. Accepts 'id', 'domain', 'path',
    111      *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false, an empty array, or 'none' to disable
    112      *                                              `ORDER BY` clause. Default 'id'.
     111     *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false,
     112     *                                              an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
    113113     *     @type string       $order                How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
    114114     *     @type string       $domain               Limit results to those affiliated with a given network ID.
     
    133133            'offset'               => '',
    134134            'no_found_rows'        => true,
    135             'orderby'              => '',
     135            'orderby'              => 'id',
    136136            'order'                => 'ASC',
    137137            'domain'               => '',
  • trunk/tests/phpunit/tests/multisite/networkQuery.php

    r37894 r38102  
    6060    }
    6161
     62    public function test_wp_network_query_by_network__in_with_order() {
     63        $expected = array( self::$network_ids['wordpress.org/'], self::$network_ids['make.wordpress.org/'] );
     64
     65        $q = new WP_Network_Query();
     66        $found = $q->query( array(
     67            'fields'      => 'ids',
     68            'network__in' => $expected,
     69            'order'       => 'ASC',
     70        ) );
     71
     72        $this->assertEquals( $expected, $found );
     73
     74        $found = $q->query( array(
     75            'fields'      => 'ids',
     76            'network__in' => $expected,
     77            'order'       => 'DESC',
     78        ) );
     79
     80        $this->assertEquals( array_reverse( $expected ), $found );
     81    }
     82
    6283    public function test_wp_network_query_by_network__in_with_single_id() {
    6384        $expected = array( self::$network_ids['wordpress.org/'] );
Note: See TracChangeset for help on using the changeset viewer.