Making WordPress.org


Ignore:
Timestamp:
02/21/2020 01:37:06 AM (5 years ago)
Author:
dd32
Message:

Theme Directory: Add some debugging to try to figure out the cause of none, or 1 theme only showing up on the Theme Directory homepage.

See #3215.

File:
1 edited

Legend:

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

    r9364 r9524  
    450450        $cache_key = sanitize_key( __METHOD__ . ':' . get_locale() . ':' . md5( serialize( $this->request ) . serialize( $this->fields ) ) );
    451451        if ( false !== ( $this->response = wp_cache_get( $cache_key, $this->cache_group ) ) && empty( $this->request->cache_buster ) ) {
    452             return;
     452
     453            // DEBUG - Attempt to skip the cache when it only contains one theme when it should contain many.
     454            if (
     455                isset( $this->request->browse ) &&
     456                'popular' === $this->request->browse &&
     457                $this->response->info['results'] <= 1
     458            ) {
     459                // The cache is bad. Don't use it.
     460                $this->response = false;
     461            } else {
     462                // The cache is good, use it.
     463                return;
     464            }
    453465        }
    454466
     
    461473        if ( empty( $this->request->fields ) ) {
    462474            $this->request->fields = array();
    463         }
    464 
    465         // DEBUG
    466         if ( function_exists( 'slack_dm' ) && isset( $wp_query->query_vars['browse'] ) && 'featured' === $wp_query->query_vars['browse'] && 1 === $this->result->found_posts ) {
    467             slack_dm( print_r( $this->request, 1 ), 'obenland' );
    468             slack_dm( print_r( $wp_query, 1 ), 'obenland' );
    469475        }
    470476
     
    485491        foreach ( (array) $this->result->posts as $theme ) {
    486492            $this->response->themes[] = $this->fill_theme( $theme );
     493        }
     494
     495        // DEBUG - Try to find out why the cache for the popular/featured views occasionally only include 1 theme.
     496        if (
     497            function_exists( 'slack_dm' ) &&
     498            ( 1 === $this->response->info['results'] || 0 === $this->response->info['results'] ) &&
     499            isset( $this->request->browse ) &&
     500            'popular' === $this->request->browse
     501        ) {
     502            slack_dm( $_SERVER['REQUEST_URI'], 'dd32' );
     503            slack_dm( print_r( $this->request, 1 ), 'dd32' );
     504            slack_dm( print_r( $wp_query, 1 ), 'dd32' );
    487505        }
    488506
Note: See TracChangeset for help on using the changeset viewer.