Skip to content

Commit d59c930

Browse files
authored
Merge pull request #1199 from cloudinary/fix/suppress-filters-internal-queries
Suppress content filters on internal asset bookkeeping queries
2 parents f8c6b64 + 7f7cf79 commit d59c930

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎php/class-assets.php‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,19 @@ private function process_parent_assets( $parent_id, $callback ) {
601601
return;
602602
}
603603

604-
$query_args = array(
604+
$query_args = array(
605605
'post_type' => self::POST_TYPE_SLUG,
606606
'posts_per_page' => 100,
607607
'post_parent' => $parent_id,
608608
'post_status' => array( 'inherit', 'draft' ),
609609
'fields' => 'ids',
610610
'update_post_meta_cache' => false,
611611
'update_post_term_cache' => false,
612+
// Internal bookkeeping query over our own post type: do not run
613+
// third-party content filters (e.g. `the_posts`) meant for
614+
// public-facing queries. The query is fully specified, so the
615+
// filters VIP protects (posts_where/join/orderby) are not relied on.
616+
'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters
612617
);
613618
$query = new \WP_Query( $query_args );
614619
$previous_total = $query->found_posts;
@@ -987,6 +992,11 @@ protected function init_asset_parents() {
987992
'no_found_rows' => true,
988993
'update_post_meta_cache' => false,
989994
'update_post_term_cache' => false,
995+
// Internal bookkeeping query over our own post type: do not run
996+
// third-party content filters (e.g. `the_posts`) meant for
997+
// public-facing queries. The query is fully specified, so the
998+
// filters VIP protects (posts_where/join/orderby) are not relied on.
999+
'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters
9901000
);
9911001
$query = new \WP_Query( $args );
9921002
$this->asset_parents = array();

0 commit comments

Comments
 (0)