-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Bug Description
The code in the vip-go-mu-plugins repo has deprecated the use of wpcom_vip_get_page_by_path which throws a deprecated error via the WP core _deprecated_function callback.
Automattic/vip-go-mu-plugins@213d797
The WordPressVIPMinimum.Functions.RestrictedFunctions sniff provides a warning which states you should use wpcom_vip_get_page_by_path in place of get_page_by_path
VIP-Coding-Standards/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php
Lines 272 to 279 in 8687674
| 'get_page_by_path' => [ | |
| 'type' => 'warning', | |
| 'message' => '%s() is highly discouraged due to not being cached; please use wpcom_vip_get_page_by_path() instead.', | |
| 'functions' => [ | |
| 'get_page_by_path', | |
| ], | |
| ], | |
| ]; |
I see there was an issue [#801] started and closed for this which suggests a trac ticket will be switching the function to WP_Query but the sniff was left in place although the function was deprecated.
Within the vip-go-mu-plugins repo the sniff is ignored and the deprecated function is still being called.
https://github.com/Automattic/vip-go-mu-plugins/blob/495b22d3965a6173fb6c83c703ea15e1cd0f81fc/search/es-wp-query/class-es-wp-query-wrapper.php#L550-L553
This can be confusing:
- The sniff says to use the deprecated function.
- The deprecated function throws a deprecated error.
- Ultimately, after tracing everything you end up using the core function with an ignored sniff.
It would simplify/streamline things to remove the sniff.
Minimal Code Snippet
get_page_by_path( $page_path, $output, $post_type );Error Code
145 | WARNING | get_page_by_path() is highly discouraged due to not being cached; please
| | use wpcom_vip_get_page_by_path() instead.
| | (WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_path_get_pa
ge_by_path)
Environment
Use php -v and composer show to get versions.
| Question | Answer |
|---|---|
| PHP version | 8.1.27 |
| PHP_CodeSniffer version | 3.9.0 |
| VIPCS version | 3.0.0 |
| WordPressCS version | 3.0.1 |
Tested Against main branch?
- [ x ] I have verified the issue still exists in the
mainbranch of VIPCS. - [ x ] I have verified the issue still exists in the
developbranch of VIPCS.