Skip to content

Commit 12f5236

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents c5a63a9 + b9a9790 commit 12f5236

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ PHP NEWS
3333
- PGSQL:
3434
. Fixed bug GH-13354 (pg_execute/pg_send_query_params/pg_send_execute
3535
with null value passed by reference). (George Barbarosie)
36+
. Fixed bug GH-13519 (PGSQL_CONNECT_FORCE_RENEW not working with persistent
37+
connections. (David Carlier)
3638

3739
- Standard:
3840
. Fixed bug GH-13279 (Instable array during in-place modification in uksort).

ext/pgsql/pgsql.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
566566

567567
/* try to find if we already have this link in our persistent list */
568568
if ((le = zend_hash_find_ptr(&EG(persistent_list), str.s)) == NULL) { /* we don't */
569+
newpconn:
569570
if (PGG(max_links) != -1 && PGG(num_links) >= PGG(max_links)) {
570571
php_error_docref(NULL, E_WARNING,
571572
"Cannot create new link. Too many open links (" ZEND_LONG_FMT ")", PGG(num_links));
@@ -594,6 +595,12 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
594595
PGG(num_links)++;
595596
PGG(num_persistent)++;
596597
} else { /* we do */
598+
if ((connect_type & PGSQL_CONNECT_FORCE_NEW)) {
599+
if (zend_hash_del(&EG(persistent_list), str.s) != SUCCESS) {
600+
goto err;
601+
}
602+
goto newpconn;
603+
}
597604
if (le->type != le_plink) {
598605
goto err;
599606
}

ext/pgsql/tests/gh13519.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
GH-13519 - PGSQL_CONNECT_FORCE_NEW with persistent connections.
3+
--EXTENSIONS--
4+
pgsql
5+
--SKIPIF--
6+
<?php include("skipif.inc"); ?>
7+
--FILE--
8+
<?php
9+
include 'config.inc';
10+
11+
$db1 = pg_pconnect($conn_str);
12+
$pid1 = pg_get_pid($db1);
13+
for ($i = 0; $i < 3; $i ++) {
14+
$db2 = pg_pconnect($conn_str);
15+
var_dump($pid1 === pg_get_pid($db2));
16+
}
17+
for ($i = 0; $i < 3; $i ++) {
18+
$db2 = pg_pconnect($conn_str, PGSQL_CONNECT_FORCE_NEW);
19+
var_dump($pid1 === pg_get_pid($db2));
20+
pg_close($db2);
21+
}
22+
pg_close($db1);
23+
?>
24+
--EXPECT--
25+
bool(true)
26+
bool(true)
27+
bool(true)
28+
bool(false)
29+
bool(false)
30+
bool(false)

0 commit comments

Comments
 (0)