Making WordPress.org

Changeset 5194


Ignore:
Timestamp:
03/29/2017 02:48:32 PM (10 years ago)
Author:
dd32
Message:

Plugin Directory: Clear the caches used by the plugins info endpoint in addition to the update check caches.
Ensure the plugin info cache key won't hit the memcache key size limits by md5'ing plugin slugs >200char.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-api-update-updater.php

    r4727 r5194  
    9292                wp_cache_delete( $plugin_details_cache_key, 'update-check-3' );
    9393
     94                // Clear plugin info caches also
     95                if ( defined( 'GLOTPRESS_LOCALES_PATH' ) && GLOTPRESS_LOCALES_PATH ) {
     96                        require GLOTPRESS_LOCALES_PATH;
     97
     98                        $locales = array_filter( array_values( wp_list_pluck( \GP_Locales::locales(), 'wp_locale' ) ) );
     99
     100                        foreach ( $locales as $locale ) {
     101                                $cache_key = "plugin_information:"
     102                                        . ( strlen( $plugin_slug ) > 200 ? 'md5:' . md5( $plugin_slug ) : $plugin_slug )
     103                                        . ":{$locale}";
     104                                wp_cache_delete( $cache_key, 'plugin_api_info' );
     105                        }
     106                }
     107
    94108                return true;
    95109        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php

    r4572 r5194  
    101101         */
    102102        protected function plugin_information_cache_key( $request ) {
    103                 return 'plugin_information:' . $request->slug . ':' . ( $request->locale ?: 'en_US' );
     103                return 'plugin_information:'
     104                        . ( strlen( $request->slug ) > 200 ? 'md5:' . md5( $request->slug ) : $request->slug )
     105                        . ':' . ( $request->locale ?: 'en_US' );
    104106        }
    105107
Note: See TracChangeset for help on using the changeset viewer.