PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.17
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.17
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
← All changes | includes/API/V1/Product_Variations_Controller.php +10 -4 1.10.4 → 1.10.17 View file →
@@ -288,8 +288,9 @@
288 288
289 289 // Meta fields to search.
290 290 $meta_fields = Barcode_Field::search_keys();
291 291
292 + $meta_placeholders = implode( ', ', array_fill( 0, \count( $meta_fields ), '%s' ) );
292 293 $search_conditions = array();
293 294
294 295 foreach ( $search_terms as $term ) {
295 296 $term = $n . $wpdb->esc_like( $term ) . $n;
@@ -294,15 +295,20 @@
294 295 foreach ( $search_terms as $term ) {
295 296 $term = $n . $wpdb->esc_like( $term ) . $n;
296 297
297 298 // Search in meta fields.
298 - foreach ( $meta_fields as $field ) {
299 - $search_conditions[] = $wpdb->prepare( '(pm1.meta_value LIKE %s AND pm1.meta_key = %s)', $term, $field );
300 - }
299 + // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table names come from $wpdb; $meta_placeholders is a generated list of %s placeholders, and the keys themselves are passed to prepare() as arguments.
300 + $search_conditions[] = $wpdb->prepare(
301 + "EXISTS (
302 + SELECT 1 FROM {$wpdb->postmeta} AS wcpos_search_meta WHERE wcpos_search_meta.post_id = {$wpdb->posts}.ID AND wcpos_search_meta.meta_key IN ($meta_placeholders) AND wcpos_search_meta.meta_value LIKE %s
303 + )",
304 + array_merge( $meta_fields, array( $term ) )
305 + );
306 + // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
301 307 }
302 308
303 309 if ( ! empty( $search_conditions ) ) {
304 - $search = ' AND (' . implode( ' OR ', $search_conditions ) . ') ';
310 + $search = ' AND (' . implode( ' AND ', $search_conditions ) . ') ';
305 311 if ( ! is_user_logged_in() ) {
306 312 $search .= " AND ($wpdb->posts.post_password = '') ";
307 313 }
308 314 }