From 8c550a274f938da5ccdf3a32e14587a688bf727c Mon Sep 17 00:00:00 2001 From: Clement Boirie Date: Mon, 24 Jun 2024 22:21:57 +0200 Subject: [PATCH 1/4] docs: add documentation for `WordPress.DB.SlowDBQuery` --- WordPress/Docs/DB/SlowDBQueryStandard.xml | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 WordPress/Docs/DB/SlowDBQueryStandard.xml diff --git a/WordPress/Docs/DB/SlowDBQueryStandard.xml b/WordPress/Docs/DB/SlowDBQueryStandard.xml new file mode 100644 index 0000000000..93dbbb6b83 --- /dev/null +++ b/WordPress/Docs/DB/SlowDBQueryStandard.xml @@ -0,0 +1,83 @@ + + + + + + + + array( + array( + 'taxonomy' => 'color', + 'field' => 'slug', + 'terms' => array( + 'blue', + 'red', + ) + ) + ) + ) +); + ]]> + + + array( + array( + 'key' => 'color', + 'compare' => 'IN', + 'value' => array( + 'blue', + 'red', + ) + ) + ) + ) +); + ]]> + + + + + 'is_featured' + ), +); + ]]> + + + 'is_featured', + 'meta_value' => true + ), +); + ]]> + + + From 585ebfcb64a585337e84240a87dfb64bbaf57967 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 10 Feb 2026 10:56:53 -0300 Subject: [PATCH 2/4] Improve documentation for `WordPress.DB.SlowDBQuery` - Rewrite standard text to mention all four flagged keys, clarify that both array assignments and query-parameter strings are detected. - Replace code examples with examples that stay within 48-character limit and use `` tags. - Remove second code comparison that incorrectly showed `tax_query` and `meta_key` as valid when the sniff warns on all four keys. --- WordPress/Docs/DB/SlowDBQueryStandard.xml | 72 ++++------------------- 1 file changed, 11 insertions(+), 61 deletions(-) diff --git a/WordPress/Docs/DB/SlowDBQueryStandard.xml b/WordPress/Docs/DB/SlowDBQueryStandard.xml index 93dbbb6b83..79d10e4b95 100644 --- a/WordPress/Docs/DB/SlowDBQueryStandard.xml +++ b/WordPress/Docs/DB/SlowDBQueryStandard.xml @@ -5,78 +5,28 @@ > - + array( - array( - 'taxonomy' => 'color', - 'field' => 'slug', - 'terms' => array( - 'blue', - 'red', - ) - ) - ) - ) +$args = array( + 'post_type' => 'post', ); - ]]> - - - array( - array( - 'key' => 'color', - 'compare' => 'IN', - 'value' => array( - 'blue', - 'red', - ) - ) - ) - ) -); - ]]> - - - - - 'is_featured' - ), -); +$query = 'post_type=post&orderby=date'; ]]> - + 'is_featured', - 'meta_value' => true - ), +$args = array( + 'meta_key' => 'color', + 'meta_value' => 'blue', ); + +$query = 'post_type=post&meta_key=featured'; ]]> From 63ff8ec1334f36981ea91ae2382b8dd56bf952fe Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 26 Feb 2026 08:01:26 -0300 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- WordPress/Docs/DB/SlowDBQueryStandard.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/Docs/DB/SlowDBQueryStandard.xml b/WordPress/Docs/DB/SlowDBQueryStandard.xml index 79d10e4b95..789e11bc7a 100644 --- a/WordPress/Docs/DB/SlowDBQueryStandard.xml +++ b/WordPress/Docs/DB/SlowDBQueryStandard.xml @@ -11,9 +11,9 @@ 'post', -); +) ); $query = 'post_type=post&orderby=date'; @@ -21,10 +21,10 @@ $query = 'post_type=post&orderby=date'; meta_key' => 'color', 'meta_value' => 'blue', -); +) ); $query = 'post_type=post&meta_key=featured'; ]]> From 4e8f54cc055d7672e764894cd0552daad30fb25d Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 5 Mar 2026 09:58:10 -0300 Subject: [PATCH 4/4] Use different variable name for query string examples --- WordPress/Docs/DB/SlowDBQueryStandard.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/Docs/DB/SlowDBQueryStandard.xml b/WordPress/Docs/DB/SlowDBQueryStandard.xml index 789e11bc7a..230c7fafb6 100644 --- a/WordPress/Docs/DB/SlowDBQueryStandard.xml +++ b/WordPress/Docs/DB/SlowDBQueryStandard.xml @@ -16,7 +16,7 @@ $query = new WP_Query( array( ) ); -$query = 'post_type=post&orderby=date'; +$args = 'post_type=post&orderby=date'; ]]> @@ -26,7 +26,7 @@ $query = new WP_Query( array( 'meta_value' => 'blue', ) ); -$query = 'post_type=post&meta_key=featured'; +$args = 'post_type=post&meta_key=featured'; ]]>