Skip to content

Commit 88145ff

Browse files
committed
Merge branch 'PHP-8.6'
* PHP-8.6: ext/pdo_pgsql: Clear the notice callback when a persistent handle is released
2 parents f020453 + 1bc1503 commit 88145ff

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎ext/pdo_pgsql/pgsql_driver.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,8 @@ static void pdo_pgsql_request_shutdown(pdo_dbh_t *dbh)
14261426
}
14271427
PQclear(res);
14281428
}
1429+
1430+
pdo_pgsql_cleanup_notice_callback(H);
14291431
}
14301432

14311433
static bool pdo_pgsql_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Pdo\Pgsql::setNoticeCallback() does not outlive the request on a persistent connection
3+
--EXTENSIONS--
4+
pdo
5+
pdo_pgsql
6+
--SKIPIF--
7+
<?php
8+
require __DIR__ . '/config.inc';
9+
require dirname(__DIR__, 2) . '/pdo/tests/pdo_test.inc';
10+
PDOTest::skip();
11+
?>
12+
--CONFLICTS--
13+
server
14+
--FILE--
15+
<?php
16+
require __DIR__ . '/config.inc';
17+
include __DIR__ . '/../../../sapi/cli/tests/php_cli_server.inc';
18+
19+
$code = '$db = new Pdo\Pgsql(' . var_export($config['ENV']['PDOTEST_DSN'], true) . ', null, null, [PDO::ATTR_PERSISTENT => true]);' . <<<'PHP'
20+
if (isset($_GET['set'])) {
21+
$db->setNoticeCallback(function ($message) {
22+
echo trim($message), "\n";
23+
});
24+
}
25+
$db->exec("DO $$ BEGIN RAISE NOTICE 'request {$_GET['n']}'; END $$");
26+
echo "request {$_GET['n']} done\n";
27+
PHP;
28+
29+
$args = ['-d', 'extension_dir=' . ini_get('extension_dir')];
30+
foreach (['pdo', 'pdo_pgsql'] as $ext) {
31+
$args[] = '-d';
32+
$args[] = 'extension=' . (PHP_OS_FAMILY === 'Windows' ? 'php_' : '') . $ext . '.' . PHP_SHLIB_SUFFIX;
33+
}
34+
if (php_ini_loaded_file()) {
35+
$args[] = '-c';
36+
$args[] = php_ini_loaded_file();
37+
}
38+
php_cli_server_start($code, 'index.php', $args);
39+
40+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?n=1&set=1');
41+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?n=2');
42+
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?n=3&set=1');
43+
?>
44+
--EXPECT--
45+
NOTICE: request 1
46+
request 1 done
47+
request 2 done
48+
NOTICE: request 3
49+
request 3 done

0 commit comments

Comments
 (0)