diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index d53d2ca63c0..5d3efe12e55 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -419,6 +419,10 @@ options: } /* the connection failed; things will tidy up in free_storage */ + if (is_persistent) { + dbh->refcount--; + } + /* XXX raise exception */ zend_restore_error_handling(&zeh); if (!EG(exception)) { diff --git a/ext/pdo_mysql/tests/construct_persistent_failure.phpt b/ext/pdo_mysql/tests/construct_persistent_failure.phpt new file mode 100644 index 00000000000..65c3b65329e --- /dev/null +++ b/ext/pdo_mysql/tests/construct_persistent_failure.phpt @@ -0,0 +1,16 @@ +--TEST-- +Failure when creating persistent connection +--EXTENSIONS-- +pdo_mysql +--FILE-- + true, + ]); +} catch (PDOException $e) { + echo "Caught\n"; +} +?> +--EXPECT-- +Caught