Prior to PHP 8.1, PostgreSQL extension returned and accepted database connections and results as resource objects. As part of PHP's resource to object migration, these resource types are migrated to class objects. All functions that returned a resource now return class objects instead, and all functions that accepted resource objects now accept the new class object, making this migration opaque with only the caveat being how a resource object is validated and closed.
In PEAR::DB, the DB_pgsql class is implemented on the assumption that the returned result is a PHP resource reference. In particular, the implementation type-casts the result to an integer which is used as an array index, which is no longer possible with the object implementation. In addition, there are checks using is_resource() which will fail on PHP 8, as this function only returns true for the resource implementation.
The class needs to be updated to handle both implementations, in order to support older PHP versions as well as continuing to run on PHP >= 8.1.
Since PHP 8.1, the postgres connection methods now return a PHP object rather than a resource.
From https://php.watch/versions/8.1/PgSQL-resource:
In PEAR::DB, the
DB_pgsql
class is implemented on the assumption that the returned result is a PHPresource
reference. In particular, the implementation type-casts the result to an integer which is used as an array index, which is no longer possible with the object implementation. In addition, there are checks usingis_resource()
which will fail on PHP 8, as this function only returns true for theresource
implementation.The class needs to be updated to handle both implementations, in order to support older PHP versions as well as continuing to run on PHP >= 8.1.