Query var normalization should be hardened to avoid infinite space
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- php, wordpress
- Domain
- backend, performance
Research direction
Start with plugins/optimization-detective/storage/data.php, reading od_get_normalized_query_vars() and od_get_url_metrics_slug(), then inspect the od_can_optimize_response() conditions in plugins/optimization-detective/optimization.php. Trace how 404, search, archive, and query-string requests produce od_url_metrics posts. Done means the project has an agreed rule that bounds query-var permutations without incorrectly grouping responses.
Written by the indexing model from the issue text.
Description
The post_name for an od_url_metrics post is comprised of an MD5-hash (via od_get_url_metrics_slug()) of the normalized query vars as returned by od_get_normalized_query_vars(). The normalization is done to avoid creating more od_url_metrics posts than are needed.
For example, when a 404 is returned the URL could contain anything. A request for /?p=123456789 results in query vars including array( 'p' => 123456789 ) even when the post doesn't exist. Every 404 response should be the same, so there is no need to have separate od_url_metrics posts for each 404 response. (In fact, is_404() should perhaps be included in the conditions used by od_can_optimize_response(), although in practice this will be the case since od_get_cache_purge_post_id() will be null.) This is already the case for search queries (when is_search()), since the URL space for searches is by definition unconstrained.) But the situation gets complicated with other types or archive queries. For example, hour, minute, and second are all valid public query vars to get posts by date. Or you can add tag and cat query vars with arbitrary comma-separated lists of tags and categories to create more possible permutations of query vars that will result in unique slug for an od_url_metrics post. How should this be handled?
Note that od_get_normalized_query_vars() isn't sorting the array keys, which is also needed for normalization, $wp->query_vars is populated by iterating over public_query_vars so in practice this shouldn't be a problem.
To guard against infinite permutations in query vars, we should perhaps disable optimization if pretty permalinks aren't enabled and/or if any public query vars are added via $_GET on top of the pretty permalink.
- Dominant language
- PHP
- Stars
- 461
- Forks
- 165
- Avg merge
- 11h 12m
- Merged PRs (30d)
- 28
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WordPress/performance
-
[Plugin] Optimization Detective [Type] Enhancement ContributorDay
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
WordPress/performance#2224 · 2 comments · 1 reaction ·
-
[Plugin] Modern Image Formats [Type] Enhancement Needs Discussion
WordPress/performance#2662 · 1 assignee ·
-
[Type] Bug
WordPress/performance#2643 · 4 comments · 1 assignee ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WordPress/performance#2640 · 3 comments ·
-
[Plugin] Optimization Detective [Type] Bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
WordPress/performance#2622 · 8 comments ·
All issues in WordPress/performance
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getgrav/grav-plugin-api#45 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RSS-Bridge/rss-bridge#5098 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
phingofficial/phing#2025 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
silverstripe/developer-docs#911 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100