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

Performance/WPQueryParams: defer to the parent sniff #780

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Aug 25, 2023

This commit removes the custom token target + custom logic from this sniff in favour of deferring to the logic in the parent sniff - as discussed in #589.

To that end, the keys which were handled in the custom process_token() logic have now been added to the getGroups() array.

As the logic for whether or not an error message should be thrown is different for each group, an extra 'name' key has been added to each group to allow the callback() function to distinguish what group the detected key came from.

It also updates the error message being used to better cover both keys being looked for, as well as mention this only applies when the array is passed to get_posts() (in an attempt to remove some of the confusion reported in #672).

Note: this is a BC-break as the error codes for the two out of the three existing checks change!

  • WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn is now WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in.
  • WordPressVIPMinimum.Performance.WPQueryParams.SuppressFiltersTrue is now WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters.
  • The WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude error code, as introduced in WPQueryParams: sniff for exclude array key being set #589, remains the same.

Fixes #594

This commit removes the custom token target + custom logic from this sniff in favour of deferring to the logic in the parent sniff - as discussed in 589.

To that end, the keys which were handled in the custom `process_token()` logic have now been added to the `getGroups()` array.

As the logic for whether or not an error message should be thrown is different for each group, an extra `'name'` key has been added to each group to allow the `callback()` function to distinguish what group the detected key came from.

It also updates the error message being used to better cover both keys being looked for, as well as mention this only applies when the array is passed to `get_posts()` (in an attempt to remove some of the confusion reported in 672).

Note: this is a BC-break as the error codes for the two out of the three existing checks change!
* `WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn` is now `WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in`.
* `WordPressVIPMinimum.Performance.WPQueryParams.SuppressFiltersTrue` is now `WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters`.
* The `WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude` error code, as introduced in 589, remains the same.

Fixes 594
@jrfnl jrfnl added this to the 3.0.0 milestone Aug 25, 2023
@jrfnl jrfnl requested a review from a team as a code owner August 25, 2023 18:01
Copy link
Contributor

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GaryJones GaryJones merged commit 5228fdf into develop Aug 25, 2023
@GaryJones GaryJones deleted the 3.0/fix/369-594-wpqueryparams-change-group-name branch August 25, 2023 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move post__not_in sniff to use the grouping in new abstract of WPQueryParamsSniff
2 participants