Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r41918 r42343  
    9292     *     @type array        $network__in          Array of network IDs to include. Default empty.
    9393     *     @type array        $network__not_in      Array of network IDs to exclude. Default empty.
    94      *     @type bool         $count                Whether to return a network count (true) or array of network objects.
    95      *                                              Default false.
    96      *     @type string       $fields               Network fields to return. Accepts 'ids' (returns an array of network IDs)
    97      *                                              or empty (returns an array of complete network objects). Default empty.
    98      *     @type int          $number               Maximum number of networks to retrieve. Default empty (no limit).
    99      *     @type int          $offset               Number of networks to offset the query. Used to build LIMIT clause.
    100      *                                              Default 0.
    101      *     @type bool         $no_found_rows        Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
    102      *     @type string|array $orderby              Network status or array of statuses. Accepts 'id', 'domain', 'path',
    103      *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false,
    104      *                                              an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
    105      *     @type string       $order                How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
    106      *     @type string       $domain               Limit results to those affiliated with a given domain. Default empty.
    107      *     @type array        $domain__in           Array of domains to include affiliated networks for. Default empty.
    108      *     @type array        $domain__not_in       Array of domains to exclude affiliated networks for. Default empty.
    109      *     @type string       $path                 Limit results to those affiliated with a given path. Default empty.
    110      *     @type array        $path__in             Array of paths to include affiliated networks for. Default empty.
    111      *     @type array        $path__not_in         Array of paths to exclude affiliated networks for. Default empty.
    112      *     @type string       $search               Search term(s) to retrieve matching networks for. Default empty.
     94     *     @type bool         $count                Whether to return a network count (true) or array of network objects.
     95     *                                              Default false.
     96     *     @type string       $fields               Network fields to return. Accepts 'ids' (returns an array of network IDs)
     97     *                                              or empty (returns an array of complete network objects). Default empty.
     98     *     @type int          $number               Maximum number of networks to retrieve. Default empty (no limit).
     99     *     @type int          $offset               Number of networks to offset the query. Used to build LIMIT clause.
     100     *                                              Default 0.
     101     *     @type bool         $no_found_rows        Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
     102     *     @type string|array $orderby              Network status or array of statuses. Accepts 'id', 'domain', 'path',
     103     *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false,
     104     *                                              an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
     105     *     @type string       $order                How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
     106     *     @type string       $domain               Limit results to those affiliated with a given domain. Default empty.
     107     *     @type array        $domain__in           Array of domains to include affiliated networks for. Default empty.
     108     *     @type array        $domain__not_in       Array of domains to exclude affiliated networks for. Default empty.
     109     *     @type string       $path                 Limit results to those affiliated with a given path. Default empty.
     110     *     @type array        $path__in             Array of paths to include affiliated networks for. Default empty.
     111     *     @type array        $path__not_in         Array of paths to exclude affiliated networks for. Default empty.
     112     *     @type string       $search               Search term(s) to retrieve matching networks for. Default empty.
    113113     *     @type bool         $update_network_cache Whether to prime the cache for found networks. Default true.
    114114     * }
     
    145145     * @since 4.6.0
    146146     *
    147      *
    148147     * @param string|array $query WP_Network_Query arguments. See WP_Network_Query::__construct()
    149148     */
     
    205204        unset( $_args['fields'] );
    206205
    207         $key = md5( serialize( $_args ) );
     206        $key          = md5( serialize( $_args ) );
    208207        $last_changed = wp_cache_get_last_changed( 'networks' );
    209208
    210         $cache_key = "get_network_ids:$key:$last_changed";
     209        $cache_key   = "get_network_ids:$key:$last_changed";
    211210        $cache_value = wp_cache_get( $cache_key, 'networks' );
    212211
     
    218217
    219218            $cache_value = array(
    220                 'network_ids' => $network_ids,
     219                'network_ids'    => $network_ids,
    221220                'found_networks' => $this->found_networks,
    222221            );
    223222            wp_cache_add( $cache_key, $cache_value, 'networks' );
    224223        } else {
    225             $network_ids = $cache_value['network_ids'];
     224            $network_ids          = $cache_value['network_ids'];
    226225            $this->found_networks = $cache_value['found_networks'];
    227226        }
     
    302301                if ( is_int( $_key ) ) {
    303302                    $_orderby = $_value;
    304                     $_order = $order;
     303                    $_order   = $order;
    305304                } else {
    306305                    $_orderby = $_key;
    307                     $_order = $_value;
     306                    $_order   = $_value;
    308307                }
    309308
     
    406405        $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) );
    407406
    408         $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
    409         $join = isset( $clauses['join'] ) ? $clauses['join'] : '';
    410         $where = isset( $clauses['where'] ) ? $clauses['where'] : '';
     407        $fields  = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
     408        $join    = isset( $clauses['join'] ) ? $clauses['join'] : '';
     409        $where   = isset( $clauses['where'] ) ? $clauses['where'] : '';
    411410        $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
    412         $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
     411        $limits  = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
    413412        $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
    414413
     
    520519        if ( $orderby == 'network__in' ) {
    521520            $network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) );
    522             $parsed = "FIELD( {$wpdb->site}.id, $network__in )";
     521            $parsed      = "FIELD( {$wpdb->site}.id, $network__in )";
    523522        } elseif ( $orderby == 'domain_length' || $orderby == 'path_length' ) {
    524             $field = substr( $orderby, 0, -7 );
     523            $field  = substr( $orderby, 0, -7 );
    525524            $parsed = "CHAR_LENGTH($wpdb->site.$field)";
    526525        } elseif ( in_array( $orderby, $allowed_keys ) ) {
Note: See TracChangeset for help on using the changeset viewer.