WordPress.org

Making WordPress.org


Ignore:
Timestamp:
11/22/17 11:31:00 (4 weeks ago)
Author:
ocean90
Message:

Translate: Don't fill the caches with empty values on query failures.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/cli/class-update-caches.php

    r3002 r6157  
    1111    private $cache_group = 'wporg-translate'; 
    1212 
     13    private $running_all = false; 
     14 
    1315    /** 
    1416     * Update all caches. 
    1517     */ 
    1618    public function all() { 
     19        $this->running_all = true; 
    1720        $this->contributors_count(); 
    1821        $this->translation_status(); 
    1922        $this->existing_locales(); 
     23        $this->running_all = false; 
    2024    } 
    2125 
     
    3337        } 
    3438 
    35         $locales = GP::$translation_set->existing_locales(); 
     39        $locales   = GP::$translation_set->existing_locales(); 
    3640        $db_counts = $wpdb->get_results( 
    3741            "SELECT `locale`, COUNT( DISTINCT user_id ) as `count` FROM {$wpdb->user_translations_count} WHERE `accepted` > 0 GROUP BY `locale`", 
    3842            OBJECT_K 
    3943        ); 
     44 
     45        if ( ! $db_counts || ! $locales ) { 
     46            if ( $this->running_all ) { 
     47                WP_CLI::warning( 'Retrieving contributors count failed.' ); 
     48                return; 
     49            } else { 
     50                WP_CLI::error( 'Retrieving contributors count failed.' ); 
     51            } 
     52        } 
    4053 
    4154        $counts = array(); 
     
    6174 
    6275        if ( ! isset( $wpdb->project_translation_status ) ) { 
    63             WP_CLI::error( 'The stats plugin seems not to be activated.' ); 
    64             return; 
     76            if ( $this->running_all ) { 
     77                WP_CLI::warning( 'Retrieving translation status failed: The stats plugin seems not to be activated.' ); 
     78                return; 
     79            } else { 
     80                WP_CLI::error( 'Retrieving translation status failed: The stats plugin seems not to be activated.' ); 
     81            } 
    6582        } 
    6683 
     
    7188            2, 'default' // 2 = wp/dev 
    7289        ), OBJECT_K ); 
     90 
     91        if ( ! $translation_status ) { 
     92            if ( $this->running_all ) { 
     93                WP_CLI::warning( 'Retrieving translation status failed.' ); 
     94                return; 
     95            } else { 
     96                WP_CLI::error( 'Retrieving translation status failed.' ); 
     97            } 
     98        } 
    7399 
    74100        wp_cache_set( 'translation-status', $translation_status, $this->cache_group ); 
     
    84110        $existing_locales = GP::$translation_set->existing_locales(); 
    85111 
     112        if ( ! $existing_locales ) { 
     113            if ( $this->running_all ) { 
     114                WP_CLI::warning( 'Retrieving existing locales failed.' ); 
     115                return; 
     116            } else { 
     117                WP_CLI::error( 'Retrieving existing locales failed.' ); 
     118            } 
     119        } 
     120 
    86121        wp_cache_set( 'existing-locales', $existing_locales, $this->cache_group ); 
    87122        WP_CLI::success( 'Existing locales were updated.' ); 
Note: See TracChangeset for help on using the changeset viewer.