php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64603 Implement check_liveness for PDO_Firebird
Submitted: 2013-04-07 07:11 UTC Modified: 2023-12-22 02:20 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: slavb18 at gmail dot com Assigned: ramsey (profile)
Status: Closed Package: PDO Firebird
PHP Version: 5.3.23 OS: Any
Private report: No CVE-ID: None
 [2013-04-07 07:11 UTC] slavb18 at gmail dot com
Description:
------------
PHP PDO class is missing ability to close persistent connection:
__destruct does not close it, even if I call setAttribute(PDO::ATTR_PERSISTENT,FALSE) before destruction
May be __destruct should analyze PDO::ATTR_PERSISTENT attribute or there should be explicit function to close persistent connection.

Need to close invalid (shutdown) peristent connection demonstrate example below:

Example with firebird:
1. establish persistent connect in php
2. shutdown connection on server
3. try to get persistent connect from php again
there will be error "General error: -902 connection shutdown"

I can check connection validity in my pdo derived class like this:
	public function isValid(){
		$valid=TRUE;
		try {
			$this->beginTransaction();
			$this->commit();
		} catch (PDOException $e){
			$valid=FALSE;
		}
		return $valid;
	}

but I can not "refresh" or "close" my broken connection, there is no function to free it in php connection pool


Patches

php5-bug64603.patch (last revision 2013-09-18 05:26 UTC by slavb18 at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-07 07:13 UTC] slavb18 at gmail dot com
there is similiar Bug #40681 with oracle
 [2013-04-07 07:24 UTC] slavb18 at gmail dot com
may be there is also third way to resolve problem

1. PDO class should have function
public function isValid(){
    return TRUE; // or some embedded functional like start/finish transaction ? dont know how it work with other drivers
}
2. derived class override & implement method isValid() (like in my example)
3. php before returning PDO class from connection pool should call isValid() method, and if validation the result is false, then automatically refresh connection
 [2013-05-25 09:21 UTC] michael at mjburgess dot co dot uk
I've confirmed this
 [2013-09-18 05:28 UTC] slavb18 at gmail dot com
with pdo_firebird_check_liveness now works ok,
no more shutdown connections returned to php
 [2021-06-09 10:41 UTC] cmb@php.net
-Summary: missing function to close persistent connection +Summary: Implement check_liveness for PDO_Firebird -Package: PDO related +Package: PDO Firebird
 [2021-06-09 10:41 UTC] cmb@php.net
> with pdo_firebird_check_liveness now works ok,

Right.  When a new persistent connection is established, and the
driver implements the check_liveness method, it is called, and if
the connection is no longer alive, a new connection is
established.
 [2023-12-22 02:20 UTC] ramsey@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ramsey
 [2023-12-22 02:20 UTC] ramsey@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.

Fixed in https://github.com/php/php-src/pull/12757
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 15:01:36 2024 UTC