Making WordPress.org


Ignore:
Timestamp:
02/14/2020 05:08:35 AM (5 years ago)
Author:
dd32
Message:

Plugin Directory: Skip outdated plugins from being included in the Jetpack Sitemaps.

This may cause OOM fatals due to the usage of get_post() in Template::is_plugin_outdated() which may exhaust the in-memory object-cache cache.

Fixes #5025.

File:
1 edited

Legend:

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

    r9501 r9506  
    4141        add_filter( 'pre_update_option_jetpack_options', array( $this, 'filter_jetpack_options' ) );
    4242        add_filter( 'jetpack_sitemap_post_types', array( $this, 'jetpack_sitemap_post_types' ) );
     43        add_filter( 'jetpack_sitemap_skip_post', array( $this, 'jetpack_sitemap_skip_post' ), 10, 2 );
    4344        add_action( 'template_redirect', array( $this, 'prevent_canonical_for_plugins' ), 9 );
    4445        add_action( 'template_redirect', array( $this, 'custom_redirects' ), 1 );
     
    13741375
    13751376        return $post_types;
     1377    }
     1378
     1379    /**
     1380     * Skip outdated plugins in Jetpack Sitemaps.
     1381     *
     1382     * @param bool $skip If this post should be excluded from Sitemaps.
     1383     * @param object $plugin_db_row A row from the wp_posts table.
     1384     * @return bool
     1385     */
     1386    public function jetpack_sitemap_skip_post( $skip, $plugin_db_row ) {
     1387        if ( Template::is_plugin_outdated( $plugin_db_row->ID ) ) {
     1388            $skip = true;
     1389        }
     1390
     1391        return $skip;
    13761392    }
    13771393
Note: See TracChangeset for help on using the changeset viewer.