Skip to content

Commit 73d8e6d

Browse files
authored
Merge pull request #814 from Automattic/fix/remove-get-page-by-title-error
End restricting usage of get_page_by_title()
2 parents cd46915 + 4c83c0b commit 73d8e6d

File tree

8 files changed

+6
-23
lines changed

8 files changed

+6
-23
lines changed

Diff for: WordPress-VIP-Go/ruleset-test.inc

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ get_next_post(); // Warning.
130130
get_previous_post_link(); // Warning.
131131
get_next_post_link(); // Warning.
132132

133-
// WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_title_get_page_by_title
134-
wpcom_vip_get_page_by_title(); // Ok.
135-
get_page_by_title( $page_title ); // Warning + Message.
133+
134+
135+
136136

137137
// WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_children
138138
get_child(); // Ok.

Diff for: WordPress-VIP-Go/ruleset-test.php

-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
129 => 1,
155155
130 => 1,
156156
131 => 1,
157-
135 => 1,
158157
139 => 1,
159158
142 => 1,
160159
146 => 1,
@@ -304,9 +303,6 @@
304303
123 => [
305304
'attachment_url_to_postid() is uncached, please use wpcom_vip_attachment_url_to_postid() instead.',
306305
],
307-
135 => [
308-
'get_page_by_title() is uncached, please use wpcom_vip_get_page_by_title() instead.',
309-
],
310306
139 => [
311307
'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/',
312308
],

Diff for: WordPress-VIP-Go/ruleset.xml

-4
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@
152152
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post_link">
153153
<type>warning</type>
154154
</rule>
155-
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_title_get_page_by_title">
156-
<type>warning</type>
157-
<message>%s() is uncached, please use wpcom_vip_get_page_by_title() instead.</message>
158-
</rule>
159155
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_children">
160156
<type>warning</type>
161157
<severity>3</severity>

Diff for: WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php

-7
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ public function getGroups() {
8080
'switch_to_blog',
8181
],
8282
],
83-
'get_page_by_title' => [
84-
'type' => 'error',
85-
'message' => '%s() is prohibited, please use wpcom_vip_get_page_by_title() instead.',
86-
'functions' => [
87-
'get_page_by_title',
88-
],
89-
],
9083
'url_to_postid' => [
9184
'type' => 'error',
9285
'message' => '%s() is prohibited, please use wpcom_vip_url_to_postid() instead.',

Diff for: WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ $wp_rewrite->flush_rules(); // Error.
5555
switch_blog(); // Ok - similarly-named function to switch_to_blog().
5656
switch_to_blog( $blogid ); // Warning.
5757

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

6161
wpcom_vip_url_to_postid( $url ); // Ok - VIP recommended version of url_to_postid().
6262
url_to_postid( $url ); // Error.

Diff for: WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function getErrorList() {
3535
43 => 1,
3636
46 => 1,
3737
50 => 1,
38-
59 => 1,
3938
62 => 1,
4039
75 => 1,
4140
76 => 1,

Diff for: WordPressVIPMinimum/ruleset-test.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ $wp_rewrite->flush_rules(); // Error.
322322
attachment_url_to_postid( $url ); // Error.
323323

324324
switch_to_blog( $blogid ); // Warning.
325-
get_page_by_title( $page_title ); // Error.
325+
326326
url_to_postid( $url ); // Error.
327327
\add_role(); // Error.
328328

Diff for: WordPressVIPMinimum/ruleset-test.php

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
320 => 1,
9393
321 => 1,
9494
322 => 1,
95-
325 => 1,
9695
326 => 1,
9796
327 => 1,
9897
333 => 1,

0 commit comments

Comments
 (0)