WordPress.org

Making WordPress.org

Changeset 9526


Ignore:
Timestamp:
02/21/2020 02:08:17 AM (22 months ago)
Author:
dd32
Message:

Theme Directory: Don't use the global $wp_query object when querying themes.

This was causing cached results to be affected by other query params that WP_Query accepts through $_GET.

This will cause an increase in queries on same pages, but should be unnoticed thanks to the heavy caching we employ on these pages.

Debug left in to ignore caches with only 1 result, can be removed in a few hours after all caches expire.

Fixes #3215.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php

    r9525 r9526  
    426426     */
    427427    public function query_themes() {
    428         global $wp_query;
    429 
    430428        // Set which fields wanted by default:
    431429        $defaults = array(
     
    451449        if ( false !== ( $this->response = wp_cache_get( $cache_key, $this->cache_group ) ) && empty( $this->request->cache_buster ) ) {
    452450
     451            // TODO: Remove this debug after Feb 21st 2020. See #3215.
    453452            // DEBUG - Attempt to skip the cache when it only contains one theme when it should contain many.
    454453            if (
     
    463462                return;
    464463            }
    465         }
    466 
    467         if ( isset( $wp_query ) && $wp_query->query_vars ) {
    468             $this->result = $wp_query;
    469         } else {
    470             $this->result = $this->perform_wp_query();
    471         }
     464
     465        }
     466
     467        $this->result = $this->perform_wp_query();
    472468
    473469        if ( empty( $this->request->fields ) ) {
     
    492488            $this->response->themes[] = $this->fill_theme( $theme );
    493489        }
    494 
    495         /*
    496         // DEBUG - Try to find out why the cache for the popular/featured views occasionally only include 1 theme.
    497         if (
    498             function_exists( 'slack_dm' ) &&
    499             ( 1 === $this->response->info['results'] || 0 === $this->response->info['results'] ) &&
    500             isset( $this->request->browse ) &&
    501             'popular' === $this->request->browse
    502         ) {
    503             slack_dm( $_SERVER['REQUEST_URI'], 'dd32' );
    504             slack_dm( print_r( $this->request, 1 ), 'dd32' );
    505             slack_dm( print_r( $wp_query, 1 ), 'dd32' );
    506         } */
    507490
    508491        wp_cache_set( $cache_key, $this->response, $this->cache_group, $this->cache_life );
Note: See TracChangeset for help on using the changeset viewer.