Making WordPress.org

Changeset 13758


Ignore:
Timestamp:
05/30/2024 04:21:10 AM (23 months ago)
Author:
dd32
Message:

Theme Directory: Add additional checks to the themes api before marking a theme as 404.

This checks that there were no DB errors on the pageload, and that we don't have any cached update-check data.

This should reduce the chances of a query failure causing a theme to be marked as missing.

Location:
sites/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/themes/info/1.0/index.php

    r12850 r13758  
    147147
    148148// Cache when a theme doesn't exist. See the validation handler above.
    149 if ( 'theme_information' == $action && isset( $slug ) && 404 == http_response_code() ) {
     149if (
     150    'theme_information' == $action &&
     151    isset( $slug ) &&
     152    404 == http_response_code() &&
     153    // Validate that the theme doesn't exist for update-checks, as a sanity check.
     154    ! wp_cache_get( $slug, 'theme-update-check' ) &&
     155    // And that there were no DB errors.
     156    empty( $wpdb->last_error )
     157) {
    150158    wp_cache_set( $slug, 'not_found', 'theme_information_error', WEEK_IN_SECONDS );
    151159}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/themes-api.php

    r12848 r13758  
    33 * Adjustments for the Themes API.
    44 */
     5
     6// Mark it as a global group whenever the theme directory is loaded.
     7wp_cache_add_global_groups( 'theme-update-check' );
    58
    69/**
     
    1114 */
    1215function wporg_themes_update_check( $post_id, $current_version ) {
    13     $slug        = get_post( $post_id )->post_name;
    14     $cache_group = 'theme-update-check';
    15     wp_cache_add_global_groups( $cache_group );
     16    $slug = get_post( $post_id )->post_name;
    1617
    1718    $theme_meta = array(
     
    2122    );
    2223
    23     wp_cache_set( $slug, $theme_meta, $cache_group );
     24    wp_cache_set( $slug, $theme_meta, 'theme-update-check' );
    2425
    2526    // Delete the error cache if this theme is new.
Note: See TracChangeset for help on using the changeset viewer.