Skip to content

Commit 7f4ace8

Browse files
committed
PDO - Added PHP::disconnect and PHP::isConnected and refactored free object.
Added disconnect for __destruct alternative to disconnect from db, related to bug #40681 and requests #62065 and #67473. Added PHP::isConnected to yield current connection status. PDO to produce SQLSTATE error 01002 "Disconnect error" and in accordance with error execution mode when database interaction prompted on disconnected PDO. Fixed bug #63343 in rework of PDO pdo_dbh_free_storage logic to avoid transaction rollback against persistent db connection. Integrated regular resource with persistent connection for end-of-request hook to invoke persistent shutdown and rollback. Added pdo_is_persisted and pdo_list_entry_from_key helpers to determine when persistent db handler is actively registered as resource, avoiding opaque use of _pdo_dbh_t::refcount to this end. Updated php_pdo_internal_construct_driver to consume added list entry helper and to check _pdo_dbh_t::is_closed in addition to liveness when validating a discovered persistent db connection for re-use. Removed extraneous call to zend_list_close given that only a persistent destructor is defined for the _pdo_dbh_t resource that zend_list_close does not invoke. Fixed potential for bad memory access in persistent connections from former PDO objects, once the connection has been replaced due to liveness check failure. The resource was freed without invalidating other PDO object references, but now the resource will not be freed until the last referring PDO object is freed. Made _pdo_dbh_t::refcount accurate and consistent, regardless of persistent connection, to represent count of PDO object's referencing the handle. In the case of persistent connections, the count was +1, and in the case of non-persistent connections, never decremented.
1 parent d9ca72f commit 7f4ace8

File tree

10 files changed

+371
-53
lines changed

10 files changed

+371
-53
lines changed

ext/pdo/pdo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ PHP_MINIT_FUNCTION(pdo)
263263
zend_hash_init(&pdo_driver_hash, 0, NULL, NULL, 1);
264264
zend_hash_init(&pdo_driver_specific_ce_hash, 0, NULL, NULL, 1);
265265

266-
le_ppdo = zend_register_list_destructors_ex(NULL, php_pdo_pdbh_dtor,
266+
le_ppdo = zend_register_list_destructors_ex(php_pdo_pdbh_request_dtor, php_pdo_pdbh_dtor,
267267
"PDO persistent database", module_number);
268268

269269
pdo_exception_ce = register_class_PDOException(spl_ce_RuntimeException);

0 commit comments

Comments
 (0)