Automattic / VIP-Coding-Standards

PHP_CodeSniffer ruleset to enforce WordPress VIP coding standards.
https://wpvip.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/
Other
236 stars 40 forks source link

Deprecate suggesting VIP-equivalent cached functions: wpcom_vip_get_page_by_path(), wpcom_vip_term_exists() and wpcom_vip_get_page_by_title() #801

Closed rebeccahum closed 9 months ago

rebeccahum commented 1 year ago

What code should not be reported as a violation?

Since the introduction of WP 6.0+, some functions (namely wpcom_vip_get_page_by_path(), wpcom_vip_term_exists() and wpcom_vip_get_page_by_title()) we previously suggested using the VIP-equivalent are now cached: https://docs.wpvip.com/technical-references/caching/uncached-functions/#h-previously-uncached-wordpress-core-functions.

We should deprecate suggesting the below since it's no longer accurate:

https://github.com/Automattic/VIP-Coding-Standards/blob/fbcc951c40378d188b0b054a76d626c792b0d537/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php#L286-L291 https://github.com/Automattic/VIP-Coding-Standards/blob/fbcc951c40378d188b0b054a76d626c792b0d537/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php#L83-L88 https://github.com/Automattic/VIP-Coding-Standards/blob/fbcc951c40378d188b0b054a76d626c792b0d537/WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php#L105-L111

GaryJones commented 9 months ago

term_exists() was handled in #812.

GaryJones commented 9 months ago

get_page_by_title() has some interesting changes.

In https://core.trac.wordpress.org/ticket/36905 it was switched to use WP_Query internally, and thus now included caching for WP 6.1.

However, as of https://core.trac.wordpress.org/ticket/57041 and WP 6.2, this change was reverted, and the function became deprecated in favour of WP_Query.

This function deprecation is included in WPCS.

So now, the question becomes - should we:

GaryJones commented 9 months ago

get_page_by_path() did have a reliance on WP_Query, but that was reverted and as this time https://core.trac.wordpress.org/ticket/56689 is still open.

GaryJones commented 9 months ago

As the three functions have been addressed one way or another, this can be closed.