[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Mon, 02 Nov 2026 20:04:31 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143239@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-11-02T14:54:21-05:00 Commit: https://github.com/php/php-src/commit/1bc1503a540bf7638c311762eda9743e0039ea47 Raw diff: https://github.com/php/php-src/commit/1bc1503a540bf7638c311762eda9743e0039ea47.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: ext/pdo_pgsql: Clear the notice callback when a persistent handle is released Changed paths: A ext/pdo_pgsql/tests/pdopgsql_setNoticeCallback_persistent.phpt M NEWS M ext/pdo_pgsql/pgsql_driver.c Diff: diff --git a/NEWS b/NEWS index e78542913b0f..a5211bd35856 100644 --- a/NEWS +++ b/NEWS @@ -169,6 +169,9 @@ PHP NEWS - PDO_PGSQL: . Fixed bug GH-24461 (DISCARD ALL on persistent connection cleanup drops PgBouncer's prepared statements). (David Carlier, Artem Ukrainskiy) + . Fixed a use-after-free when a persistent connection receives a notice + after the request that called Pdo\Pgsql::setNoticeCallback() has ended. + (Ilia Alshanetsky) - PDO_SQLite: . Fixed bug GH-24990 (Statement unusable after a failed execute()). (lazerg) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index bdb8a067e61b..20edb7f67339 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -1426,6 +1426,8 @@ static void pdo_pgsql_request_shutdown(pdo_dbh_t *dbh) } PQclear(res); } + + pdo_pgsql_cleanup_notice_callback(H); } static bool pdo_pgsql_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val) diff --git a/ext/pdo_pgsql/tests/pdopgsql_setNoticeCallback_persistent.phpt b/ext/pdo_pgsql/tests/pdopgsql_setNoticeCallback_persistent.phpt new file mode 100644 index 000000000000..15c1d6d69432 --- /dev/null +++ b/ext/pdo_pgsql/tests/pdopgsql_setNoticeCallback_persistent.phpt @@ -0,0 +1,49 @@ +--TEST-- +Pdo\Pgsql::setNoticeCallback() does not outlive the request on a persistent connection +--EXTENSIONS-- +pdo +pdo_pgsql +--SKIPIF-- +<?php +require __DIR__ . '/config.inc'; +require dirname(__DIR__, 2) . '/pdo/tests/pdo_test.inc'; +PDOTest::skip(); +?> +--CONFLICTS-- +server +--FILE-- +<?php +require __DIR__ . '/config.inc'; +include __DIR__ . '/../../../sapi/cli/tests/php_cli_server.inc'; + +$code = '$db = new Pdo\Pgsql(' . var_export($config['ENV']['PDOTEST_DSN'], true) . ', null, null, [PDO::ATTR_PERSISTENT => true]);' . <<<'PHP' +if (isset($_GET['set'])) { + $db->setNoticeCallback(function ($message) { + echo trim($message), "\n"; + }); +} +$db->exec("DO $$ BEGIN RAISE NOTICE 'request {$_GET['n']}'; END $$"); +echo "request {$_GET['n']} done\n"; +PHP; + +$args = ['-d', 'extension_dir=' . ini_get('extension_dir')]; +foreach (['pdo', 'pdo_pgsql'] as $ext) { + $args[] = '-d'; + $args[] = 'extension=' . (PHP_OS_FAMILY === 'Windows' ? 'php_' : '') . $ext . '.' . PHP_SHLIB_SUFFIX; +} +if (php_ini_loaded_file()) { + $args[] = '-c'; + $args[] = php_ini_loaded_file(); +} +php_cli_server_start($code, 'index.php', $args); + +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?n=1&set=1'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?n=2'); +echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/?n=3&set=1'); +?> +--EXPECT-- +NOTICE: request 1 +request 1 done +request 2 done +NOTICE: request 3 +request 3 done

« previous php.cvs (#143239) next »