WordPress.org

Make WordPress Core

Ticket #32504: 32504-dontcache-max_num_pages.diff

File 32504-dontcache-max_num_pages.diff, 1.3 KB (added by spacedmonkey, 3 years ago)
  • src/wp-includes/class-wp-network-query.php

     
    229229                        $cache_value = array(
    230230                                'network_ids' => $network_ids,
    231231                                'found_networks' => $this->found_networks,
    232                                 'max_num_pages' => $this->max_num_pages,
    233232                        );
    234233                        wp_cache_add( $cache_key, $cache_value, 'networks' );
    235234                } else {
    236235                        $network_ids = $cache_value['network_ids'];
    237236                        $this->found_networks = $cache_value['found_networks'];
    238                         $this->max_num_pages = $cache_value['max_num_pages'];
    239237                }
    240238
     239                if ( $this->found_networks && $this->query_vars['number'] ) {
     240                        $this->max_num_pages = ceil( $this->found_networks / $this->query_vars['number'] );
     241                }
     242               
    241243                // If querying for a count only, there's nothing more to do.
    242244                if ( $this->query_vars['count'] ) {
    243245                        // $network_ids is actually a count in this case.
     
    477479                        $found_networks_query = apply_filters( 'found_networks_query', 'SELECT FOUND_ROWS()', $this );
    478480
    479481                        $this->found_networks = (int) $wpdb->get_var( $found_networks_query );
    480                         $this->max_num_pages = ceil( $this->found_networks / $this->query_vars['number'] );
    481482                }
    482483        }
    483484