From 7f7cf797102ba3e310d22495aefd82f2972fc93c Mon Sep 17 00:00:00 2001 From: Utkarsh Patel Date: Tue, 14 Jul 2026 14:36:58 +0530 Subject: [PATCH] Suppress content filters on internal asset bookkeeping queries init_asset_parents() and process_parent_assets() run internal WP_Query lookups over Cloudinary's own asset post type. These are not public-facing content queries, but they still fire third-party the_posts/posts_results filters, which can cause a theme/plugin to run expensive per-query work (e.g. author-archive injection) on every one of Cloudinary's internal queries until the request exhausts memory. Set suppress_filters => true on these fully-specified internal queries so they skip content filters. The WordPressVIPMinimum SuppressFilters rule is suppressed with an explanation: these queries do not rely on the posts_where/join/orderby filters the rule protects. --- php/class-assets.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/php/class-assets.php b/php/class-assets.php index afdd8e79..5447f2f9 100644 --- a/php/class-assets.php +++ b/php/class-assets.php @@ -601,7 +601,7 @@ private function process_parent_assets( $parent_id, $callback ) { return; } - $query_args = array( + $query_args = array( 'post_type' => self::POST_TYPE_SLUG, 'posts_per_page' => 100, 'post_parent' => $parent_id, @@ -609,6 +609,11 @@ private function process_parent_assets( $parent_id, $callback ) { 'fields' => 'ids', 'update_post_meta_cache' => false, 'update_post_term_cache' => false, + // Internal bookkeeping query over our own post type: do not run + // third-party content filters (e.g. `the_posts`) meant for + // public-facing queries. The query is fully specified, so the + // filters VIP protects (posts_where/join/orderby) are not relied on. + 'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters ); $query = new \WP_Query( $query_args ); $previous_total = $query->found_posts; @@ -987,6 +992,11 @@ protected function init_asset_parents() { 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, + // Internal bookkeeping query over our own post type: do not run + // third-party content filters (e.g. `the_posts`) meant for + // public-facing queries. The query is fully specified, so the + // filters VIP protects (posts_where/join/orderby) are not relied on. + 'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters ); $query = new \WP_Query( $args ); $this->asset_parents = array();