Skip to content

Commit

Permalink
Merge pull request #814 from Automattic/fix/remove-get-page-by-title-…
Browse files Browse the repository at this point in the history
…error

End restricting usage of get_page_by_title()
  • Loading branch information
rebeccahum authored Feb 16, 2024
2 parents cd46915 + 4c83c0b commit 73d8e6d
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 23 deletions.
6 changes: 3 additions & 3 deletions WordPress-VIP-Go/ruleset-test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ get_next_post(); // Warning.
get_previous_post_link(); // Warning.
get_next_post_link(); // Warning.

// WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_title_get_page_by_title
wpcom_vip_get_page_by_title(); // Ok.
get_page_by_title( $page_title ); // Warning + Message.




// WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_children
get_child(); // Ok.
Expand Down
4 changes: 0 additions & 4 deletions WordPress-VIP-Go/ruleset-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
129 => 1,
130 => 1,
131 => 1,
135 => 1,
139 => 1,
142 => 1,
146 => 1,
Expand Down Expand Up @@ -304,9 +303,6 @@
123 => [
'attachment_url_to_postid() is uncached, please use wpcom_vip_attachment_url_to_postid() instead.',
],
135 => [
'get_page_by_title() is uncached, please use wpcom_vip_get_page_by_title() instead.',
],
139 => [
'get_children() is uncached and performs a no limit query. Please use get_posts or WP_Query instead. Please see: https://docs.wpvip.com/technical-references/caching/uncached-functions/',
],
Expand Down
4 changes: 0 additions & 4 deletions WordPress-VIP-Go/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post_link">
<type>warning</type>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_title_get_page_by_title">
<type>warning</type>
<message>%s() is uncached, please use wpcom_vip_get_page_by_title() instead.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_children">
<type>warning</type>
<severity>3</severity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ public function getGroups() {
'switch_to_blog',
],
],
'get_page_by_title' => [
'type' => 'error',
'message' => '%s() is prohibited, please use wpcom_vip_get_page_by_title() instead.',
'functions' => [
'get_page_by_title',
],
],
'url_to_postid' => [
'type' => 'error',
'message' => '%s() is prohibited, please use wpcom_vip_url_to_postid() instead.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ $wp_rewrite->flush_rules(); // Error.
switch_blog(); // Ok - similarly-named function to switch_to_blog().
switch_to_blog( $blogid ); // Warning.

wpcom_vip_get_page_by_title(); // Ok - VIP recommended version of get_page_by_title().
get_page_by_title( $page_title ); // Error.



wpcom_vip_url_to_postid( $url ); // Ok - VIP recommended version of url_to_postid().
url_to_postid( $url ); // Error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function getErrorList() {
43 => 1,
46 => 1,
50 => 1,
59 => 1,
62 => 1,
75 => 1,
76 => 1,
Expand Down
2 changes: 1 addition & 1 deletion WordPressVIPMinimum/ruleset-test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ $wp_rewrite->flush_rules(); // Error.
attachment_url_to_postid( $url ); // Error.

switch_to_blog( $blogid ); // Warning.
get_page_by_title( $page_title ); // Error.

url_to_postid( $url ); // Error.
\add_role(); // Error.

Expand Down
1 change: 0 additions & 1 deletion WordPressVIPMinimum/ruleset-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
320 => 1,
321 => 1,
322 => 1,
325 => 1,
326 => 1,
327 => 1,
333 => 1,
Expand Down

0 comments on commit 73d8e6d

Please sign in to comment.