diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/class-wp-network-query.php --- a/wp/wp-includes/class-wp-network-query.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/class-wp-network-query.php Fri Sep 05 18:40:08 2025 +0200 @@ -14,6 +14,7 @@ * * @see WP_Network_Query::__construct() for accepted arguments. */ +#[AllowDynamicProperties] class WP_Network_Query { /** @@ -144,7 +145,7 @@ * * @since 4.6.0 * - * @param string|array $query WP_Network_Query arguments. See WP_Network_Query::__construct() + * @param string|array $query WP_Network_Query arguments. See WP_Network_Query::__construct() for accepted arguments. */ public function parse_query( $query = '' ) { if ( empty( $query ) ) { @@ -249,7 +250,7 @@ $last_changed = wp_cache_get_last_changed( 'networks' ); $cache_key = "get_network_ids:$key:$last_changed"; - $cache_value = wp_cache_get( $cache_key, 'networks' ); + $cache_value = wp_cache_get( $cache_key, 'network-queries' ); if ( false === $cache_value ) { $network_ids = $this->get_network_ids(); @@ -261,14 +262,14 @@ 'network_ids' => $network_ids, 'found_networks' => $this->found_networks, ); - wp_cache_add( $cache_key, $cache_value, 'networks' ); + wp_cache_add( $cache_key, $cache_value, 'network-queries' ); } else { $network_ids = $cache_value['network_ids']; $this->found_networks = $cache_value['found_networks']; } if ( $this->found_networks && $this->query_vars['number'] ) { - $this->max_num_pages = ceil( $this->found_networks / $this->query_vars['number'] ); + $this->max_num_pages = (int) ceil( $this->found_networks / $this->query_vars['number'] ); } // If querying for a count only, there's nothing more to do. @@ -438,17 +439,26 @@ $groupby = ''; - $clauses = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); + $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); /** * Filters the network query clauses. * * @since 4.6.0 * - * @param string[] $clauses An associative array of network query clauses. + * @param string[] $clauses { + * Associative array of the clauses for the query. + * + * @type string $fields The SELECT clause of the query. + * @type string $join The JOIN clause of the query. + * @type string $where The WHERE clause of the query. + * @type string $orderby The ORDER BY clause of the query. + * @type string $limits The LIMIT clause of the query. + * @type string $groupby The GROUP BY clause of the query. + * } * @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference). */ - $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $clauses ), &$this ) ); + $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) ); $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; @@ -480,14 +490,14 @@ $this->sql_clauses['orderby'] = $orderby; $this->sql_clauses['limits'] = $limits; - $this->request = " - {$this->sql_clauses['select']} - {$this->sql_clauses['from']} - {$where} - {$this->sql_clauses['groupby']} - {$this->sql_clauses['orderby']} - {$this->sql_clauses['limits']} - "; + // Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841. + $this->request = + "{$this->sql_clauses['select']} + {$this->sql_clauses['from']} + {$where} + {$this->sql_clauses['groupby']} + {$this->sql_clauses['orderby']} + {$this->sql_clauses['limits']}"; if ( $this->query_vars['count'] ) { return (int) $wpdb->get_var( $this->request );