WordPress.org

Making WordPress.org

Changeset 9650


Ignore:
Timestamp:
03/31/2020 04:06:55 AM (4 months ago)
Author:
dd32
Message:

Plugin Directory: Clear memcache/db in-memory caches during XML Sitemap generation.

Fixes #5025.

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

Legend:

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

    r9647 r9650  
    33
    44use WordPressdotorg\Plugin_Directory\Admin\Customizations;
     5use WordPressdotorg\Plugin_Directory\Tools;
    56use WordPressdotorg\Plugin_Directory\Admin\Tools\Author_Cards;
    67use WordPressdotorg\Plugin_Directory\Admin\Tools\Stats_Report;
     
    13841385     */
    13851386    public function jetpack_sitemap_skip_post( $skip, $plugin_db_row ) {
     1387        static $calls = 0;
     1388        if ( $calls++ >= 50 ) {
     1389            // Clear some memory caches.
     1390            $calls = 0;
     1391            Tools::clear_memory_heavy_variables();
     1392        }
     1393
    13861394        if ( Template::is_plugin_outdated( $plugin_db_row->ID ) ) {
    13871395            $skip = true;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php

    r9008 r9650  
    538538        return $users;
    539539    }
     540
     541    /**
     542     * Clear caches for memory management.
     543     *
     544     * @static
     545     * @global \wpdb            $wpdb
     546     * @global \WP_Object_Cache $wp_object_cache
     547     */
     548    public static function clear_memory_heavy_variables() {
     549        global $wpdb, $wp_object_cache;
     550
     551        $wpdb->queries = [];
     552
     553        if ( is_object( $wp_object_cache ) ) {
     554            $wp_object_cache->cache          = [];
     555            $wp_object_cache->group_ops      = [];
     556            $wp_object_cache->memcache_debug = [];
     557        }
     558    }
    540559}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php

    r9284 r9650  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Jobs;
     3use WordPressdotorg\Plugin_Directory\Tools;
    34
    45/**
     
    314315     *
    315316     * @static
    316      * @global \wpdb            $wpdb
    317      * @global \WP_Object_Cache $wp_object_cache
     317     * @see Tools::clear_memory_heavy_variables();
    318318     */
    319319    public static function clear_memory_heavy_variables() {
    320         global $wpdb, $wp_object_cache;
    321 
    322         $wpdb->queries = [];
    323 
    324         if ( is_object( $wp_object_cache ) ) {
    325             $wp_object_cache->cache          = [];
    326             $wp_object_cache->group_ops      = [];
    327             $wp_object_cache->memcache_debug = [];
    328         }
     320        Tools::clear_memory_heavy_variables();
    329321    }
    330322
Note: See TracChangeset for help on using the changeset viewer.