diff options
author | Ahmed Abdou <email@ahmed.ro> | 2019-02-17 22:59:00 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-08-11 17:12:48 +0200 |
commit | 2fe2e5b48f8cf9a45ac2530dd0e2dca8f4287e01 (patch) | |
tree | 994e5f20b990ce660cb4208b6f3edf48d9fcfb73 /ext/pdo_pgsql/tests | |
parent | 2fa4ca95db262267aa6bd46c5e2f74aa42542fc3 (diff) | |
download | php-git-2fe2e5b48f8cf9a45ac2530dd0e2dca8f4287e01.tar.gz |
Fix #64705 errorInfo property of PDOException is null when PDO::__construct() fails
PDO driver constructors are throwing PdoException without setting
errorInfo, so create a new reusable function that throws exceptions
for PDO and will also set the errorInfo. Use this function in
pdo_mysql, pdo_sqlite, and pdo_pgsql.
Diffstat (limited to 'ext/pdo_pgsql/tests')
-rw-r--r-- | ext/pdo_pgsql/tests/bug_64705.phpt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/pdo_pgsql/tests/bug_64705.phpt b/ext/pdo_pgsql/tests/bug_64705.phpt new file mode 100644 index 0000000000..464b4d0769 --- /dev/null +++ b/ext/pdo_pgsql/tests/bug_64705.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails +--SKIPIF-- +<?php +if (!extension_loaded('pdo_pgsql')) print 'skip not loaded'; +?> +--FILE-- +<?php +$dsn = 'pgsql:host=DonotExistsHost;dbname=test;user=foo;password=wrongpass'; +try { + $pdo = new \PDO($dsn, null, null); +} catch (\PDOException $e) { + var_dump(!empty($e->errorInfo) && is_array($e->errorInfo)); +} +?> +--EXPECTF-- +bool(true)
\ No newline at end of file |