Ticket #27272: 27272_meta.diff
File 27272_meta.diff, 1.9 KB (added by , 10 years ago) |
---|
-
src/wp-includes/meta.php
1398 1398 $meta_value = trim( $meta_value ); 1399 1399 } 1400 1400 1401 switch ( $meta_type ) { 1402 case 'SIGNED': 1403 $cast_string = '%d'; 1404 break; 1405 case 'UNSIGNED': 1406 $cast_string = '%u'; 1407 break; 1408 default: 1409 $cast_string = '%s'; 1410 break; 1411 } 1412 1401 1413 switch ( $meta_compare ) { 1402 1414 case 'IN' : 1403 1415 case 'NOT IN' : 1404 $meta_compare_string = '(' . substr( str_repeat( ', %s', count( $meta_value ) ), 1 ) . ')';1416 $meta_compare_string = '(' . substr( str_repeat( ',' . $cast_string, count( $meta_value ) ), 1 ) . ')'; 1405 1417 $where = $wpdb->prepare( $meta_compare_string, $meta_value ); 1406 1418 break; 1407 1419 … … 1408 1420 case 'BETWEEN' : 1409 1421 case 'NOT BETWEEN' : 1410 1422 $meta_value = array_slice( $meta_value, 0, 2 ); 1411 $where = $wpdb->prepare( '%s AND %s', $meta_value );1423 $where = $wpdb->prepare( $cast_string . ' AND ' . $cast_string, $meta_value ); 1412 1424 break; 1413 1425 1414 1426 case 'LIKE' : 1415 1427 case 'NOT LIKE' : 1416 1428 $meta_value = '%' . $wpdb->esc_like( $meta_value ) . '%'; 1417 $where = $wpdb->prepare( '%s', $meta_value );1429 $where = $wpdb->prepare( $cast_string, $meta_value ); 1418 1430 break; 1419 1431 1420 1432 // EXISTS with a value is interpreted as '='. 1421 1433 case 'EXISTS' : 1422 1434 $meta_compare = '='; 1423 $where = $wpdb->prepare( '%s', $meta_value );1435 $where = $wpdb->prepare( $cast_string, $meta_value ); 1424 1436 break; 1425 1437 1426 1438 // 'value' is ignored for NOT EXISTS. … … 1429 1441 break; 1430 1442 1431 1443 default : 1432 $where = $wpdb->prepare( '%s', $meta_value );1444 $where = $wpdb->prepare( $cast_string, $meta_value ); 1433 1445 break; 1434 1446 1435 1447 } 1436 1448 1437 if ( $where ) {1449 if ( $where !== '' ) { 1438 1450 $sql_chunks['where'][] = "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$where}"; 1439 1451 } 1440 1452 }