PHP 8.0: PostgreSQL: Several aliased functions are deprecated

Version8.0
TypeDeprecation

PHP 8 deprecates several function aliases in PostgreSQL extension. These deprecated functions do not appear in the PHP documentation today, and all code that appear to use them are from the PHP 4 era.

However, there are several positive search results on GitHub, which hints of possible deprecation notices in PHP 8.0.

A total of 24 functions are deprecated, all of which were not documented. Last appearance of these functions in documentation appears to be from 2001.

Deprecated Function Replace with
pg_clientencoding pg_client_encoding
pg_cmdtuples pg_affected_rows
pg_errormessage pg_last_error
pg_fieldisnull pg_field_is_null
pg_fieldname pg_field_name
pg_fieldnum pg_field_num
pg_fieldprtlen pg_field_prtlen
pg_fieldsize pg_field_size
pg_fieldtype pg_field_type
pg_freeresult pg_free_result
pg_getlastoid pg_last_oid
pg_loclose pg_lo_close
pg_locreate pg_lo_create
pg_loexport pg_lo_export
pg_loimport pg_lo_import
pg_loopen pg_lo_open
pg_loread pg_lo_read
pg_loreadall pg_lo_read_all
pg_lowrite pg_lo_write
pg_numfields pg_num_fields
pg_numrows pg_num_rows
pg_result pg_fetch_result
pg_setclientencoding pg_set_client_encoding

Backwards Compatibility Impact

Deprecated functions above will raise a deprecation notice:

Deprecated: Function pg_numrows() is deprecated in ... on line ...

A simply function swap with canonical function will be the straight-forward fix. All the canonical functions are already available in PHP versions 4.2 through 8.0 and future.


Implementation