Deprecate using the implicit default PgSQL connection

The DB connection should be provided in all cases as the first argument.
The overloaded function signatures will be removed in the future.
Warn about this change.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
This commit is contained in:
George Peter Banyard 2021-01-06 04:03:25 +00:00
parent 16072074f3
commit 1f42777927
42 changed files with 311 additions and 115 deletions

View file

@ -78,8 +78,15 @@
zend_throw_error(NULL, "No PostgreSQL connection opened yet"); \
RETURN_THROWS(); \
}
/* This is a bit hacky as the macro usage is "link = FETCH_DEFAULT_LINK();" */
#define FETCH_DEFAULT_LINK() \
(PGG(default_link) ? pgsql_link_from_obj(PGG(default_link)) : NULL)
(PGG(default_link) ? pgsql_link_from_obj(PGG(default_link)) : NULL); \
php_error_docref(NULL, E_DEPRECATED, "Automatic fetching of PostgreSQL connection is deprecated")
/* Used only when creating a connection */
#define FETCH_DEFAULT_LINK_NO_WARNING() \
(PGG(default_link) ? pgsql_link_from_obj(PGG(default_link)) : NULL)
#define CHECK_PGSQL_LINK(link_handle) \
if (link_handle->conn == NULL) { \
@ -850,7 +857,7 @@ PHP_FUNCTION(pg_close)
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
if (link == FETCH_DEFAULT_LINK()) {
if (link == FETCH_DEFAULT_LINK_NO_WARNING()) {
GC_DELREF(PGG(default_link));
PGG(default_link) = NULL;
}