Skip to content

Commit ce75326

Browse files
committed
Merge branch 'true-async' into fiber-support
2 parents 74f3d38 + 97beffe commit ce75326

File tree

12 files changed

+211
-18
lines changed

12 files changed

+211
-18
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ PHP NEWS
2525
- Mbstring:
2626
. ini_set() with mbstring.detect_order changes the order of mb_detect_order
2727
as intended, since mbstring.detect_order is an INI_ALL setting. (tobee94)
28+
. Added GB18030-2022 to default encoding list for zh-CN. (HeRaNO)
2829

2930
- Opcache:
3031
. Fixed bug GH-20051 (apache2 shutdowns when restart is requested during
3132
preloading). (Arnaud, welcomycozyhom)
3233

34+
- PDO_PGSQL:
35+
. Clear session-local state disconnect-equivalent processing.
36+
(KentarouTakeda)
37+
3338
- Phar:
3439
. Support reference values in Phar::mungServer(). (ndossche)
3540
. Invalid values now throw in Phar::mungServer() instead of being silently

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES
6464
. Removed the XML_GetCurrentByteCount() libxml compatibility wrapper,
6565
as it was unused and could return the wrong result.
6666

67+
- ext/mbstring:
68+
. Added GB18030-2022 to default encoding list for zh-CN.
69+
6770
========================
6871
4. OpCode changes
6972
========================

Zend/zend_API.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4384,14 +4384,8 @@ ZEND_API void zend_get_callable_zval_from_fcc(const zend_fcall_info_cache *fcc,
43844384

43854385
ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */
43864386
{
4387-
zend_string *lname;
43884387
size_t name_len = strlen(module_name);
4389-
zend_module_entry *module;
4390-
4391-
lname = zend_string_alloc(name_len, 0);
4392-
zend_str_tolower_copy(ZSTR_VAL(lname), module_name, name_len);
4393-
module = zend_hash_find_ptr(&module_registry, lname);
4394-
zend_string_efree(lname);
4388+
zend_module_entry *module = zend_hash_str_find_ptr_lc(&module_registry, module_name, name_len);
43954389
return module ? module->version : NULL;
43964390
}
43974391
/* }}} */

ext/lexbor/lexbor/url/url.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,6 @@ lxb_url_parse_basic_h(lxb_url_parser_t *parser, lxb_url_t *url,
18171817
if (override_state != LXB_URL_STATE__UNDEF
18181818
&& url->scheme.type == LXB_URL_SCHEMEL_TYPE_FILE)
18191819
{
1820-
p -= 1;
18211820
state = LXB_URL_STATE_FILE_HOST_STATE;
18221821
goto again;
18231822
}

ext/mbstring/mbstring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ static const enum mbfl_no_encoding php_mb_default_identify_list_cn[] = {
116116
mbfl_no_encoding_ascii,
117117
mbfl_no_encoding_utf8,
118118
mbfl_no_encoding_euc_cn,
119-
mbfl_no_encoding_cp936
119+
mbfl_no_encoding_cp936,
120+
mbfl_no_encoding_gb18030_2022
120121
};
121122

122123
static const enum mbfl_no_encoding php_mb_default_identify_list_tw_hk[] = {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Default encodings in Simplified Chinese
3+
--EXTENSIONS--
4+
mbstring
5+
--INI--
6+
mbstring.language=Simplified Chinese
7+
--FILE--
8+
<?php
9+
var_dump(mb_detect_order());
10+
11+
?>
12+
--EXPECT--
13+
array(5) {
14+
[0]=>
15+
string(5) "ASCII"
16+
[1]=>
17+
string(5) "UTF-8"
18+
[2]=>
19+
string(6) "EUC-CN"
20+
[3]=>
21+
string(5) "CP936"
22+
[4]=>
23+
string(12) "GB18030-2022"
24+
}

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,20 @@ static const zend_function_entry *pdo_pgsql_get_driver_methods(pdo_dbh_t *dbh, i
13401340
}
13411341
}
13421342

1343+
static void pdo_pgsql_request_shutdown(pdo_dbh_t *dbh)
1344+
{
1345+
PGresult *res;
1346+
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
1347+
1348+
if(H->server) {
1349+
res = PQexec(H->server, "DISCARD ALL");
1350+
1351+
if(res) {
1352+
PQclear(res);
1353+
}
1354+
}
1355+
}
1356+
13431357
static bool pdo_pgsql_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val)
13441358
{
13451359
bool bval;
@@ -1383,7 +1397,7 @@ static const struct pdo_dbh_methods pgsql_methods = {
13831397
pdo_pgsql_get_attribute,
13841398
pdo_pgsql_check_liveness, /* check_liveness */
13851399
pdo_pgsql_get_driver_methods, /* get_driver_methods */
1386-
NULL,
1400+
pdo_pgsql_request_shutdown,
13871401
pgsql_handle_in_transaction,
13881402
NULL, /* get_gc */
13891403
pdo_pgsql_scanner
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
--TEST--
2+
Persistent connections: session state reset when performing disconnect-equivalent processing (general case)
3+
--EXTENSIONS--
4+
pdo_pgsql
5+
--SKIPIF--
6+
<?php
7+
require __DIR__ . '/config.inc';
8+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
9+
PDOTest::skip();
10+
?>
11+
--FILE--
12+
<?php
13+
putenv('PDOTEST_ATTR='.serialize([PDO::ATTR_PERSISTENT => true]));
14+
15+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
16+
17+
$pdo1 = PDOTest::test_factory(__DIR__ . '/common.phpt');
18+
19+
$pid1 = (int)$pdo1
20+
->query('select pg_backend_pid()::int;')
21+
->fetchColumn(0);
22+
23+
$defaultValue = (int)$pdo1
24+
->query('show log_min_duration_statement;')
25+
->fetchColumn(0);
26+
27+
$setValue = $defaultValue + 1;
28+
29+
$pdo1->exec("set log_min_duration_statement = {$setValue};");
30+
31+
$pdo1 = null;
32+
33+
$pdo2 = PDOTest::test_factory(__DIR__ . '/common.phpt');
34+
35+
$pid2 = (int)$pdo2
36+
->query('select pg_backend_pid()::int;')
37+
->fetchColumn(0);
38+
39+
assert($pid1 === $pid2);
40+
41+
$expectedValue = (int)$pdo2
42+
->query('show log_min_duration_statement;')
43+
->fetchColumn(0);
44+
45+
echo "defaultValue: {$defaultValue}\n";
46+
echo "setValue: {$setValue}\n";
47+
echo "expectedValue: {$expectedValue}\n";
48+
echo "expected value should be reset to default: " . (($expectedValue === $defaultValue) ? 'success' : 'failure') . "\n";
49+
50+
?>
51+
--EXPECTF--
52+
defaultValue: %i
53+
setValue: %d
54+
expectedValue: %i
55+
expected value should be reset to default: success
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
Persistent connections: session state reset when performing disconnect-equivalent processing (advisory lock case)
3+
--EXTENSIONS--
4+
pdo_pgsql
5+
--SKIPIF--
6+
<?php
7+
require __DIR__ . '/config.inc';
8+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
9+
PDOTest::skip();
10+
?>
11+
--FILE--
12+
<?php
13+
putenv('PDOTEST_ATTR='.serialize([PDO::ATTR_PERSISTENT => true]));
14+
15+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
16+
17+
$pdo1 = PDOTest::test_factory(__DIR__ . '/common.phpt');
18+
19+
$pid1 = (int)$pdo1
20+
->query('select pg_backend_pid()::int;')
21+
->fetchColumn(0);
22+
23+
$lockResult1 = (bool)$pdo1
24+
->query('select pg_try_advisory_lock(42)::int;')
25+
->fetchColumn(0);
26+
27+
$pdo1 = null;
28+
29+
$dsn = getenv('PDO_PGSQL_TEST_DSN');
30+
$dsn .= ';';
31+
putenv('PDO_PGSQL_TEST_DSN='.$dsn);
32+
33+
$pdo2 = PDOTest::test_factory(__DIR__ . '/common.phpt');
34+
35+
$pid2 = (int)$pdo2
36+
->query('select pg_backend_pid()::int;')
37+
->fetchColumn(0);
38+
39+
assert($pid1 !== $pid2);
40+
41+
$lockResult2 = (bool)$pdo2
42+
->query('select pg_try_advisory_lock(42)::int;')
43+
->fetchColumn(0);
44+
45+
echo "lock1: " . ($lockResult1 ? 'success' : 'failure') . "\n";
46+
echo "lock2: " . ($lockResult2 ? 'success' : 'failure') . "\n";
47+
48+
?>
49+
--EXPECT--
50+
lock1: success
51+
lock2: success
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--TEST--
2+
Persistent connections: session state reset after backend termination (interrupted case)
3+
--EXTENSIONS--
4+
pdo_pgsql
5+
--SKIPIF--
6+
<?php
7+
require __DIR__ . '/config.inc';
8+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
9+
PDOTest::skip();
10+
?>
11+
--FILE--
12+
<?php
13+
putenv('PDOTEST_ATTR='.serialize([PDO::ATTR_PERSISTENT => true]));
14+
15+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
16+
17+
$pdo1 = PDOTest::test_factory(__DIR__ . '/common.phpt');
18+
19+
$pid1 = (int)$pdo1
20+
->query('select pg_backend_pid()::int;')
21+
->fetchColumn(0);
22+
23+
$pid1 = (int)$pdo1
24+
->query('select pg_backend_pid()::int;')
25+
->fetchColumn(0);
26+
27+
$dsn = getenv('PDO_PGSQL_TEST_DSN');
28+
$dsn .= ';';
29+
putenv('PDO_PGSQL_TEST_DSN='.$dsn);
30+
31+
$pdo2 = PDOTest::test_factory(__DIR__ . '/common.phpt');
32+
33+
$pid2 = (int)$pdo2
34+
->query('select pg_backend_pid()::int;')
35+
->fetchColumn(0);
36+
37+
assert($pid1 !== $pid2);
38+
39+
$terminateResult = (bool)$pdo2
40+
->query("select pg_terminate_backend({$pid1})::int")
41+
->fetchColumn(0);
42+
43+
// Disconnect after being terminated by another connection
44+
$pdo1 = null;
45+
46+
echo 'pid of pdo1: ' . $pid1 . "\n";
47+
echo 'terminate result of pdo1 by pdo2: ' . ($terminateResult ? 'success' : 'failure') . "\n";
48+
49+
?>
50+
--EXPECTF--
51+
pid of pdo1: %d
52+
terminate result of pdo1 by pdo2: success

0 commit comments

Comments
 (0)