-
Notifications
You must be signed in to change notification settings - Fork 90
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
gppa-ignore-current-user-filter-for-admins.php
: Fixed a potential PHP error.
#728
Conversation
@@ -25,7 +25,7 @@ | |||
return $query_builder_args; | |||
} | |||
|
|||
array_pop( $query_builder_args['where'][ $filter_group_index ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this usage, this is wiping out the entire where
and effectively removing all filters from what I can see.
My guess is that the issue has to do with the filter using special_value:current_user:ID
not being the last filter in the group.
You'll need to loop through $query_builder_args['where'][ $filter_group_index ]
and find the filter that has $filter['value'] === 'special_value:current_user:ID'
and remove it from the $query_builder_args['where'][ $filter_group_index ]
array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Actually $filter_group_index does that job fine. What is happening specifically in this test scenario is that there is only 1 filter and that is using special_value:current_user:ID
. So unsetting messes up the overall structure of the $query_builder_args which is what I've fixed in the next test and pushed it. @claygriffiths
if ( count( $query_builder_args['where'][ $filter_group_index ] ) == 0 ) { | ||
$query_builder_args['where'] = array(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there are multiple groups?
For example, if $filter_group_index
is 1
here, and we have another on 2
, this would clear that out as well.
1606381
to
2d269e2
Compare
gppa-ignore-current-user-filter-for-admins.php
: Fixed an issue with snippet causing a fatal error.gppa-ignore-current-user-filter-for-admins.php
: Fixed a potential PHP error.
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2412200474/56932?folderId=3808239
Summary
The snippet causes a fatal error when used on-site to remove the current user ID filter for admins.