Skip to content

Commit 8a67fc2

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
2 parents 35a9f77 + e618474 commit 8a67fc2

4 files changed

Lines changed: 77 additions & 0 deletions

File tree

‎NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ PHP NEWS
7070
. Fix GH-22854: Fixed failed assertion when accessing mysqli property after
7171
failed reconnection. (Kamil Tekiela)
7272

73+
- MySQLnd:
74+
. Fixed field_count not resetting on OK packet. (Kamil Tekiela)
75+
7376
- Opcache:
7477
. Fixed OSS-Fuzz #546798343 (Heap-buffer-overflow in optimizer with
7578
FCCs and inlining). (ndossche)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
mysqli_stmt::$field_count is 0 for the trailing OK packet of a stored procedure
3+
--EXTENSIONS--
4+
mysqli
5+
--SKIPIF--
6+
<?php
7+
require_once 'skipifconnectfailure.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
require_once 'connect.inc';
12+
13+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
14+
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
15+
$link->query('DROP PROCEDURE IF EXISTS test_field_count_p');
16+
$link->query('CREATE PROCEDURE test_field_count_p() BEGIN SELECT 1 AS a; SELECT 2 AS b, 3 AS c; END');
17+
18+
$stmt = $link->prepare('CALL test_field_count_p()');
19+
$stmt->execute();
20+
do {
21+
var_dump($stmt->field_count);
22+
$stmt->get_result();
23+
} while ($stmt->next_result());
24+
?>
25+
--CLEAN--
26+
<?php
27+
require_once 'connect.inc';
28+
$link = new mysqli($host, $user, $passwd, $db, $port, $socket);
29+
$link->query('DROP PROCEDURE IF EXISTS test_field_count_p');
30+
?>
31+
--EXPECT--
32+
int(1)
33+
int(2)
34+
int(0)

‎ext/mysqlnd/mysqlnd_ps.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s, enum_mysqlnd_parse_e
515515

516516
stmt->state = MYSQLND_STMT_EXECUTED;
517517
if (conn->last_query_type == QUERY_UPSERT || conn->last_query_type == QUERY_LOAD_LOCAL) {
518+
stmt->field_count = conn->field_count;
518519
DBG_INF("PASS");
519520
DBG_RETURN(PASS);
520521
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
MySQL PDOStatement->columnCount() is 0 for the trailing OK packet of a stored procedure
3+
--EXTENSIONS--
4+
pdo_mysql
5+
--SKIPIF--
6+
<?php
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
8+
MySQLPDOTest::skip();
9+
?>
10+
--FILE--
11+
<?php
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13+
$db = MySQLPDOTest::factory();
14+
$db->exec('DROP PROCEDURE IF EXISTS pdo_mysql_stmt_nextrowset_columncount_p');
15+
$db->exec('CREATE PROCEDURE pdo_mysql_stmt_nextrowset_columncount_p() BEGIN SELECT 1 AS a; SELECT 2 AS b, 3 AS c; END');
16+
17+
foreach ([true, false] as $emulate) {
18+
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, $emulate);
19+
$stmt = $db->prepare('CALL pdo_mysql_stmt_nextrowset_columncount_p()');
20+
$stmt->execute();
21+
do {
22+
var_dump($stmt->columnCount());
23+
$stmt->fetchAll();
24+
} while ($stmt->nextRowset());
25+
}
26+
?>
27+
--CLEAN--
28+
<?php
29+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
30+
$db = MySQLPDOTest::factory();
31+
$db->exec('DROP PROCEDURE IF EXISTS pdo_mysql_stmt_nextrowset_columncount_p');
32+
?>
33+
--EXPECT--
34+
int(1)
35+
int(2)
36+
int(0)
37+
int(1)
38+
int(2)
39+
int(0)

0 commit comments

Comments
 (0)