Suppress content filters on internal asset bookkeeping queries#1199
Draft
utkarshcloudinary wants to merge 1 commit into
Draft
Suppress content filters on internal asset bookkeeping queries#1199utkarshcloudinary wants to merge 1 commit into
utkarshcloudinary wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Assets::init_asset_parents()andAssets::process_parent_assets()run internalWP_Querylookups over Cloudinary's own asset post type. They are pure plugin bookkeeping, but because they are normalWP_Queryinstantiations they still fire third-partythe_posts/posts_resultscontent filters.If an active theme or plugin hooks
the_postswith expensive work, that work runs on every Cloudinary internal query. This was reported on an enterprise site whose theme injects author-archive results onthe_posts(runningget_users()+count_user_posts()per query); with Cloudinary's paginated internal queries this repeated until PHP's memory limit was exhausted and pages 500'd.Change
Add
'suppress_filters' => trueto the two fully-specified internal queries so they skip content filters entirely — correct behaviour for internal bookkeeping that has nothing to do with public-facing content.Note on WordPressVIPMinimum.SuppressFilters
The VIP standard prohibits
suppress_filters => truebecause it also disablesposts_where/posts_join/posts_orderby(used by VIP infra and multilingual plugins). These two queries are fully specified by post type / parent / status and do not rely on those filters, so the rule is suppressed inline with an explanatory comment. Existing precedent for VIP-restricted query usage in this codebase:php/cache/class-cache-point.php:439.Status / caveats
have_rows()from their theme during Cloudinary activation — see separate work). This PR addresses the memory-exhaustion interaction reproduced locally against the customer theme, which is not yet confirmed to be the issue the customer currently faces.Testing
init_asset_parents()still populates asset parents correctlyprocess_parent_assets()still iterates child assets correctlythe_posts, that filter no longer runs on Cloudinary internal queries