After making a fix to my PHP application on my test server, I pushed it to my production server and the fix didn't work. After tracking it down I found that ksort() was causing index keys to overflow for integers larger than the max 32-bit signed value (2147483648) on my production server only. On my test server it would only overflow for integers larger than the max signed 64-bit integer (9223372036854775808).
Both servers (as fully as I can tell) have the same software configuration
- Ubuntu 12.10
- Kernel version: Linux version 3.0.0-15-generic-pae
PHP 5.4.6-1ubuntu1.2
- CPU on production: AMD Phenom(tm) II X4 910
- CPU on test server: AMD Athlon(tm) II X4 620
To reproduce this issue
$arr = array(2147483648 => 1, 5 => 2); ksort($arr); print_r($arr);
Outputs the following on my production server:
Array
(
[-2147483648] => 1
[5] => 2
)
The exact same code outputs the following on my test server:
Array
(
[5] => 2
[2147483648] => 1
)
I'm trying to figure out what could be causing this. Where should I be looking to narrow down why the servers have different integer sizes. Is it possible that I may have a different version of PHP (even though both appear to be the same) that was compiled with 32bit integers?