Update legacy.php for postgresql Pagination error

See #5008