diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-09 12:44:28 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-09 12:45:07 +0200 |
commit | 8f415d441381f1a074e661cffaf9f806b1d8e001 (patch) | |
tree | 1c3979989119aed6eb36d685a995d1112b9e3808 /ext/pgsql | |
parent | 3ab88831ae46078a5ffeba50b9cf66386ae0db6a (diff) | |
download | php-git-8f415d441381f1a074e661cffaf9f806b1d8e001.tar.gz |
Promote pgsql no link to Error exception
Diffstat (limited to 'ext/pgsql')
-rw-r--r-- | ext/pgsql/pgsql.c | 6 | ||||
-rw-r--r-- | ext/pgsql/tests/no_link_open.phpt | 14 |
2 files changed, 19 insertions, 1 deletions
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-- +<?php + +try { + pg_dbname(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +No PostgreSQL link opened yet |