Making WordPress.org


Ignore:
Timestamp:
05/21/2017 02:20:50 PM (9 years ago)
Author:
ocean90
Message:

Translate: Replace query for translation set slugs with a hardcoded list to fix performance issue.

See [5502].

File:
1 edited

Legend:

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

    r5502 r5503  
    220220         */
    221221        private function translation_set_slug_exists( $locale, $slug ) {
    222                 $cache_key = "translation_set_slugs:{$locale->slug}";
     222                /*$cache_key = "translation_set_slugs:{$locale->slug}";
    223223                $slugs = wp_cache_get( $cache_key, $this->cache_group );
    224224
    … …  
    231231
    232232                        wp_cache_set( $cache_key, $slugs, $this->cache_group, DAY_IN_SECONDS );
    233                 }
    234 
    235                 return in_array( $slug, $slugs, true );
     233                }*/
     234
     235                // Hardcoded list because the query above doesn't perform well due to a missing index.
     236                $slugs = [
     237                        'default' => [
     238                                'default',
     239                        ],
     240                        'de' => [
     241                                'default',
     242                                'formal',
     243                        ],
     244                        'de-ch' => [
     245                                'default',
     246                                'informal',
     247                        ],
     248                        'nl' => [
     249                                'default',
     250                                'formal',
     251                        ],
     252                        'pt' => [
     253                                'default',
     254                                'informal',
     255                        ],
     256                ];
     257
     258                if ( isset( $slugs[ $locale->slug ] ) ) {
     259                        return in_array( $slug, $slugs[ $locale->slug ], true );
     260                }
     261
     262                return in_array( $slug, $slugs['default'], true );
    236263        }
    237264
Note: See TracChangeset for help on using the changeset viewer.