| 1257 | * @ticket 27272 |
| 1258 | */ |
| 1259 | public function test_meta_query_cast_value_numeric_big() { |
| 1260 | $posts = $this->factory->post->create_many( 1 ); |
| 1261 | |
| 1262 | // Will trigger (depending on system) MySQL string to float type conversion on quoted numbers. |
| 1263 | $big_int = 0x20000000000001; // 0x20 0000 0000 0001 (53 bit integer + 1, 9007199254740993). |
| 1264 | update_post_meta( $posts[0], 'foo', $big_int - 1 ); |
| 1265 | |
| 1266 | $q = new WP_Query( array( |
| 1267 | 'update_post_meta_cache' => false, |
| 1268 | 'update_term_meta_cache' => false, |
| 1269 | 'fields' => 'ids', |
| 1270 | 'meta_query' => array( |
| 1271 | array( |
| 1272 | 'key' => 'foo', |
| 1273 | 'value' => $big_int, |
| 1274 | 'compare' => '<', |
| 1275 | 'type' => 'NUMERIC', |
| 1276 | ), |
| 1277 | ), |
| 1278 | ) ); |
| 1279 | |
| 1280 | $this->assertEquals( array( $posts[0] ), $q->posts ); |
| 1281 | } |
| 1282 | |
| 1283 | /** |
| 1284 | * @group meta |
| 1285 | * @ticket 27272 |
| 1286 | */ |
| 1287 | public function test_meta_query_cast_value_numeric_max() { |
| 1288 | $posts = $this->factory->post->create_many( 1 ); |
| 1289 | |
| 1290 | $max_int = PHP_INT_MAX; |
| 1291 | update_post_meta( $posts[0], 'foo', $max_int - 1 ); |
| 1292 | |
| 1293 | $q = new WP_Query( array( |
| 1294 | 'update_post_meta_cache' => false, |
| 1295 | 'update_term_meta_cache' => false, |
| 1296 | 'fields' => 'ids', |
| 1297 | 'meta_query' => array( |
| 1298 | array( |
| 1299 | 'key' => 'foo', |
| 1300 | 'value' => $max_int, |
| 1301 | 'compare' => '<', |
| 1302 | 'type' => 'NUMERIC', |
| 1303 | ), |
| 1304 | ), |
| 1305 | ) ); |
| 1306 | |
| 1307 | $this->assertEquals( array( $posts[0] ), $q->posts ); |
| 1308 | } |
| 1309 | |
| 1310 | /** |
| 1311 | * @group meta |