From cd82f3e2d36efa687751299e2aabec62ece5d675 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Fri, 16 Feb 2024 16:24:41 +0000 Subject: [PATCH] End restricting usage of term_exists() Since WP 6.0.0, term_exists() uses get_terms() internally`. See core.trac.wordpress.org/ticket/36949. This means that reporting this function as not being cached is not true anymore. Fixes #720. --- WordPress-VIP-Go/ruleset-test.inc | 2 +- WordPress-VIP-Go/ruleset-test.php | 1 - .../Sniffs/Functions/RestrictedFunctionsSniff.php | 7 ------- .../Tests/Functions/RestrictedFunctionsUnitTest.inc | 4 ++-- .../Tests/Functions/RestrictedFunctionsUnitTest.php | 1 - WordPressVIPMinimum/ruleset-test.inc | 2 +- WordPressVIPMinimum/ruleset-test.php | 1 - 7 files changed, 4 insertions(+), 14 deletions(-) diff --git a/WordPress-VIP-Go/ruleset-test.inc b/WordPress-VIP-Go/ruleset-test.inc index 773842b0..4a36e262 100644 --- a/WordPress-VIP-Go/ruleset-test.inc +++ b/WordPress-VIP-Go/ruleset-test.inc @@ -358,7 +358,7 @@ wpcom_vip_irc(); // Error. flush_rewrite_rules(); // Error. $wp_rewrite->flush_rules(); // Error. \add_role(); // Error. -term_exists(); // Error. + count_user_posts(); // Error. get_intermediate_image_sizes(); // Error. wp_is_mobile(); // Error. diff --git a/WordPress-VIP-Go/ruleset-test.php b/WordPress-VIP-Go/ruleset-test.php index 0fde7fbe..053d9a86 100644 --- a/WordPress-VIP-Go/ruleset-test.php +++ b/WordPress-VIP-Go/ruleset-test.php @@ -47,7 +47,6 @@ 358 => 1, 359 => 1, 360 => 1, - 361 => 1, 362 => 1, 363 => 1, 364 => 1, diff --git a/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php b/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php index 505bc5a0..8f81f4cf 100644 --- a/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php +++ b/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php @@ -102,13 +102,6 @@ public function getGroups() { 'add_role', ], ], - 'term_exists' => [ - 'type' => 'error', - 'message' => '%s() is highly discouraged due to not being cached; please use wpcom_vip_term_exists() instead.', - 'functions' => [ - 'term_exists', - ], - ], 'count_user_posts' => [ 'type' => 'error', 'message' => '%s() is highly discouraged due to not being cached; please use wpcom_vip_count_user_posts() instead.', diff --git a/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc b/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc index d6dc74ef..b4366c98 100644 --- a/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc +++ b/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc @@ -84,8 +84,8 @@ add_role( 'test' ); // Error. -wpcom_vip_term_exists(); // Ok - VIP recommended version of term_exists(). -term_exists(); // Error. + + wpcom_vip_count_user_posts(); // Ok - VIP recommended version of count_user_posts(). count_user_posts(); // Error. diff --git a/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php b/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php index e089d78e..bb5236cb 100644 --- a/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php @@ -39,7 +39,6 @@ public function getErrorList() { 62 => 1, 75 => 1, 76 => 1, - 88 => 1, 91 => 1, 94 => 1, 97 => 1, diff --git a/WordPressVIPMinimum/ruleset-test.inc b/WordPressVIPMinimum/ruleset-test.inc index 0b25bfef..fd0567c6 100644 --- a/WordPressVIPMinimum/ruleset-test.inc +++ b/WordPressVIPMinimum/ruleset-test.inc @@ -329,7 +329,7 @@ url_to_postid( $url ); // Error. -term_exists(); // Error. + count_user_posts(); // Error. wp_old_slug_redirect(); // Error. get_adjacent_post(); // Error. diff --git a/WordPressVIPMinimum/ruleset-test.php b/WordPressVIPMinimum/ruleset-test.php index 05076415..71016e82 100644 --- a/WordPressVIPMinimum/ruleset-test.php +++ b/WordPressVIPMinimum/ruleset-test.php @@ -95,7 +95,6 @@ 325 => 1, 326 => 1, 327 => 1, - 332 => 1, 333 => 1, 334 => 1, 335 => 1,