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

Stream db query args not working #1043

Open
nprasath002 opened this issue Jan 3, 2020 · 2 comments · May be fixed by #1045
Open

Stream db query args not working #1043

nprasath002 opened this issue Jan 3, 2020 · 2 comments · May be fixed by #1045

Comments

@nprasath002
Copy link

nprasath002 commented Jan 3, 2020

There is a filter in stream wp_stream_query_args to pass query arguments. However passing record__in property to the arguement does not work. Looking at the function query

		if ( ! empty( $ins ) ) {
			foreach ( $ins as $key => $value ) {
				if ( empty( $value ) || ! is_array( $value ) ) {
					continue;
				}

				$field = str_replace( array( 'record_', '__in' ), '', $key );
				$field = empty( $field ) ? 'ID' : $field;
				$type  = is_numeric( array_shift( $value ) ) ? '%d' : '%s';

				if ( ! empty( $value ) ) {
					$format = '(' . join( ',', array_fill( 0, count( $value ), $type ) ) . ')';
					$where .= $wpdb->prepare( " AND $wpdb->stream.%s IN {$format}", $field, $value ); // @codingStandardsIgnoreLine prepare okay
				}
			}
		}

Specifically line $field = str_replace( array( 'record_', '__in' ), '', $key );
For key record__in this would return __in not empty as intended.

This is true for record__not_in as well

@nprasath002 nprasath002 linked a pull request Jan 3, 2020 that will close this issue
10 tasks
@nprasath002
Copy link
Author

Created a quick PR for this #1045

@lkraav
Copy link
Contributor

lkraav commented Jan 3, 2020

Did you check open PRs? We've been working on it with @kasparsd for a while #977 #1011 unfortunately some missing plumbing systems (testing) have prevented this from landing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants