Cherry-picked PHP_INT_MAX patch from 4.0.
Cherry-picked workaround 5.3 SQLite issue from master.