Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wpcom_vip_get_page_by_path is deprecated yet sniff still suggests using it #816

Closed
mlipe-nxs opened this issue Mar 19, 2024 · 0 comments · Fixed by #817
Closed

wpcom_vip_get_page_by_path is deprecated yet sniff still suggests using it #816

mlipe-nxs opened this issue Mar 19, 2024 · 0 comments · Fixed by #817
Assignees

Comments

@mlipe-nxs
Copy link

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

'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:

  1. The sniff says to use the deprecated function.
  2. The deprecated function throws a deprecated error.
  3. 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 main branch of VIPCS.
  • [ x ] I have verified the issue still exists in the develop branch of VIPCS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants