|
| 1 | +--TEST-- |
| 2 | +PHPC-592: Property name corrupted when unserializing 64-bit integer on 32-bit platform |
| 3 | +--SKIPIF-- |
| 4 | +<?php if (4 !== PHP_INT_SIZE) { die('skip Only for 32-bit platform'); } ?> |
| 5 | +<?php require __DIR__ . "/../utils/basic-skipif.inc"?> |
| 6 | +--INI-- |
| 7 | +mongodb.debug=stderr |
| 8 | +--FILE-- |
| 9 | +<?php |
| 10 | + |
| 11 | +require_once __DIR__ . "/../utils/basic.inc"; |
| 12 | + |
| 13 | +$tests = [ |
| 14 | + '{ "x": { "$numberLong": "-2147483648" }}', |
| 15 | + '{ "x": { "$numberLong": "2147483647" }}', |
| 16 | + '{ "x": { "$numberLong": "4294967294" }}', |
| 17 | + '{ "x": { "$numberLong": "4294967295" }}', |
| 18 | + '{ "x": { "$numberLong": "9223372036854775807" }}', |
| 19 | + '{ "longFieldName": { "$numberLong": "-2147483648" }}', |
| 20 | + '{ "longFieldName": { "$numberLong": "2147483647" }}', |
| 21 | + '{ "longFieldName": { "$numberLong": "4294967294" }}', |
| 22 | + '{ "longFieldName": { "$numberLong": "4294967295" }}', |
| 23 | + '{ "longFieldName": { "$numberLong": "9223372036854775807" }}', |
| 24 | +]; |
| 25 | + |
| 26 | +foreach ($tests as $json) { |
| 27 | + printf("Test %s\n", $json); |
| 28 | + var_dump(toPHP(fromJSON($json))); |
| 29 | + echo "\n"; |
| 30 | +} |
| 31 | + |
| 32 | +?> |
| 33 | +===DONE=== |
| 34 | +<?php exit(0); ?> |
| 35 | +--EXPECTF-- |
| 36 | +Test { "x": { "$numberLong": "-2147483648" }} |
| 37 | +object(stdClass)#%d (%d) { |
| 38 | + ["x"]=> |
| 39 | + int(-2147483648) |
| 40 | +} |
| 41 | + |
| 42 | +Test { "x": { "$numberLong": "2147483647" }} |
| 43 | +object(stdClass)#%d (%d) { |
| 44 | + ["x"]=> |
| 45 | + int(2147483647) |
| 46 | +} |
| 47 | + |
| 48 | +Test { "x": { "$numberLong": "4294967295" }} |
| 49 | +[%s] PHONGO-BSON: WARNING > ENTRY: Integer overflow detected on your platform: 4294967295 |
| 50 | +object(stdClass)#%d (%d) { |
| 51 | + ["x"]=> |
| 52 | + string(10) "4294967295" |
| 53 | +} |
| 54 | + |
| 55 | +Test { "x": { "$numberLong": "9223372036854775807" }} |
| 56 | +[%s] PHONGO-BSON: WARNING > ENTRY: Integer overflow detected on your platform: 9223372036854775807 |
| 57 | +object(stdClass)#%d (%d) { |
| 58 | + ["x"]=> |
| 59 | + string(19) "9223372036854775807" |
| 60 | +} |
| 61 | + |
| 62 | +Test { "longFieldName": { "$numberLong": "-2147483648" }} |
| 63 | +object(stdClass)#%d (%d) { |
| 64 | + ["longFieldName"]=> |
| 65 | + int(-2147483648) |
| 66 | +} |
| 67 | + |
| 68 | +Test { "longFieldName": { "$numberLong": "2147483647" }} |
| 69 | +object(stdClass)#%d (%d) { |
| 70 | + ["longFieldName"]=> |
| 71 | + int(2147483647) |
| 72 | +} |
| 73 | + |
| 74 | +Test { "longFieldName": { "$numberLong": "4294967294" }} |
| 75 | +object(stdClass)#%d (%d) { |
| 76 | + ["longFieldName"]=> |
| 77 | + string(10) "4294967294" |
| 78 | +} |
| 79 | + |
| 80 | +Test { "longFieldName": { "$numberLong": "4294967295" }} |
| 81 | +[%s] PHONGO-BSON: WARNING > ENTRY: Integer overflow detected on your platform: 4294967295 |
| 82 | +object(stdClass)#%d (%d) { |
| 83 | + ["longFieldName"]=> |
| 84 | + string(10) "4294967295" |
| 85 | +} |
| 86 | + |
| 87 | +Test { "longFieldName": { "$numberLong": "9223372036854775807" }} |
| 88 | +[%s] PHONGO-BSON: WARNING > ENTRY: Integer overflow detected on your platform: 9223372036854775807 |
| 89 | +object(stdClass)#%d (%d) { |
| 90 | + ["longFieldName"]=> |
| 91 | + string(19) "9223372036854775807" |
| 92 | +} |
| 93 | + |
| 94 | +===DONE=== |
0 commit comments