-
Notifications
You must be signed in to change notification settings - Fork 116
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
Apply filter to query args Fix #355 #362
Conversation
$where .= $wpdb->prepare( " AND $wpdb->stream.ID IN ($record__in)", '' ); | ||
if ( $args[ 'record__in' ] ) { | ||
$record__in = array_filter( (array)$args[ 'record__in' ], 'is_numeric' ); | ||
$record__in_format = '(' . substr( str_repeat( ',%d', count( $record__in ) ), 1 ) . ')'; |
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.
@faishal it might be better to use array_fill
here:
$record__in_format = '(' . join( ',' array_fill( 0, count( $record__in ), '%d' ) ) . ')';
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.
@westonruter Yes it will be better, I will do that changes.
@faishal You make an excellent point about applying the filter by default, and I think it's a great idea. What do you think about adding a Then it can be overridden easily like: stream_query( array( 'hide_excluded' => false ) ); |
@fjarrett That will be good idea. /five |
All suggested changes are done |
if ( strlen( $author__not_in ) ) { | ||
$where .= $wpdb->prepare( " AND $wpdb->stream.author NOT IN ($author__not_in)", '' ); | ||
$author__not_in = array_filter( (array)$args[ 'author__not_in' ], 'is_numeric' ); | ||
$author__not_in_format = '(' . join( ',', array_fill( 0, count( $author__not_in ), '%d' ) ) . ')'; |
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.
@faishal This is causing some warnings to appear for me.
Warning: array_fill(): Number of elements must be positive in /srv/www/wordpress-trunk/wp-content/plugins/stream/includes/query.php on line 187
Warning: join(): Invalid arguments passed in /srv/www/wordpress-trunk/wp-content/plugins/stream/includes/query.php on line 187
@fjarrett sorry my bad ! Fixed by checking empty array before use |
@faishal While testing this, I've been running into some problems with other Stream extensions, namely our Data Exporter project. /cc @lukecarbis Before we merge this I think we will be forced to expand the scope of this ticket even more and introduce an option for this, which will force users to opt-in to hiding previous records. Then the default for any Stream query will be whatever this setting is. What do you think? |
@fjarrett Yeah, That will be really good option for user to choose whether they want to hide previous records or not. /five |
Silly questions: What if I want to hide all evidence of Frankie Jarrett's existence by hiding his previous records, but I also want to stop recording changes from the Comments connector without hiding previous entries? If I have not chosen to hide previous records, how do I know when the current exclude settings took effect? |
But the general idea of leaving the Visibility choice up to the user will help them accomplish 1 of 2 objectives:
|
@fjarrett done |
Apply filter to query args Fix #355
I noticed that the Stream filters don't respect the exclude settings. For example, I set the author exclude to Is this the intended behavior? |
@lukecarbis Good catch! If the visibility is set to Hide Previous Records then I think excluded items should be omitted from the dropdown filters entirely, as originally discussed in #223 /cc @faishal |
@lukecarbis realy good catch. I am working on it. |
Fix Stream filter issue with exclude settings #362
Add
stream_query_args
filter with callbackWP_Stream_Settings::remove_excluded_record_filter
will fix issue.