From: Nikita Popov Date: Wed, 9 Sep 2020 10:44:28 +0000 (+0200) Subject: Promote pgsql no link to Error exception X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f415d441381f1a074e661cffaf9f806b1d8e001;p=php Promote pgsql no link to Error exception --- diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index b0883769d1..118ecabbf3 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -74,7 +74,11 @@ #define PGSQL_RETURN_OID(oid) RETURN_LONG((zend_long)oid) #endif -#define CHECK_DEFAULT_LINK(x) if ((x) == NULL) { php_error_docref(NULL, E_WARNING, "No PostgreSQL link opened yet"); RETURN_FALSE; } +#define CHECK_DEFAULT_LINK(x) \ + if ((x) == NULL) { \ + zend_throw_error(NULL, "No PostgreSQL link opened yet"); \ + RETURN_THROWS(); \ + } #define FETCH_DEFAULT_LINK() PGG(default_link) #ifndef HAVE_PQFREEMEM diff --git a/ext/pgsql/tests/no_link_open.phpt b/ext/pgsql/tests/no_link_open.phpt new file mode 100644 index 0000000000..051ce38f19 --- /dev/null +++ b/ext/pgsql/tests/no_link_open.phpt @@ -0,0 +1,14 @@ +--TEST-- +Using pg function with default link while no link open +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECT-- +No PostgreSQL link opened yet