Making WordPress.org

Changeset 2361


Ignore:
Timestamp:
01/24/2016 06:43:43 PM (11 years ago)
Author:
ocean90
Message:

Translate, Plugin Directory: Reduce number of database queries by fetching all existing sets at once.

See #1352.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-plugin-directory/cli/set-plugin-project.php

    r2344 r2361  
    231231                }
    232232
     233                $existing_sets = array();
     234                foreach ( GP::$translation_set->by_project_id( $project->id ) as $set ) {
     235                        $existing_sets[ $set->locale . ':' . $set->slug ] = true;
     236                }
     237
    233238                foreach ( $translation_sets as $ts ) {
    234                         if ( empty( $ts ) || empty( $ts->name ) ) {
    235                                 continue;
    236                         }
    237 
    238                         $existing = GP::$translation_set->by_project_id_slug_and_locale( $project->id, $ts->slug, $ts->locale );
    239                         if ( ! empty( $existing ) ) {
     239                        if ( isset( $existing_sets[ $ts->locale . ':' . $ts->slug ] ) ) {
     240                                // This translation set already exists.
    240241                                continue;
    241242                        }
Note: See TracChangeset for help on using the changeset viewer.