Skip to content

Performance/WPQueryParams: defer to the parent sniff#780

Merged
GaryJones merged 1 commit into
developfrom
3.0/fix/369-594-wpqueryparams-change-group-name
Aug 25, 2023
Merged

Performance/WPQueryParams: defer to the parent sniff#780
GaryJones merged 1 commit into
developfrom
3.0/fix/369-594-wpqueryparams-change-group-name

Conversation

@jrfnl

@jrfnl jrfnl commented Aug 25, 2023

Copy link
Copy Markdown
Collaborator

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

@GaryJones GaryJones left a comment

Copy link
Copy Markdown
Contributor

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