Skip to content

Commit 1a3b85c

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-8267: MySQLi uses unsupported format specifier on Windows
2 parents 8922706 + 22f8886 commit 1a3b85c

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

ext/mysqli/php_mysqli_structs.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ typedef struct {
127127

128128
#ifdef PHP_WIN32
129129
#define PHP_MYSQLI_API __declspec(dllexport)
130-
#define MYSQLI_LLU_SPEC "%I64u"
131-
#define MYSQLI_LL_SPEC "%I64d"
132130
#ifndef L64
133131
#define L64(x) x##i64
134132
#endif
@@ -139,16 +137,17 @@ typedef __int64 my_longlong;
139137
# else
140138
# define PHP_MYSQLI_API
141139
# endif
142-
/* we need this for PRIu64 and PRId64 */
143-
#include <inttypes.h>
144-
#define MYSQLI_LLU_SPEC "%" PRIu64
145-
#define MYSQLI_LL_SPEC "%" PRId64
146140
#ifndef L64
147141
#define L64(x) x##LL
148142
#endif
149143
typedef int64_t my_longlong;
150144
#endif
151145

146+
/* we need this for PRIu64 and PRId64 */
147+
#include <inttypes.h>
148+
#define MYSQLI_LLU_SPEC "%" PRIu64
149+
#define MYSQLI_LL_SPEC "%" PRId64
150+
152151
#ifdef ZTS
153152
#include "TSRM.h"
154153
#endif

ext/mysqli/tests/gh8267.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug GH-8267 (MySQLi uses unsupported format specifier on Windows)
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 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
14+
$mysqli->query("DROP TABLE IF EXISTS foo");
15+
$mysqli->query("CREATE TABLE foo (id BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (id))");
16+
$mysqli->query("INSERT INTO foo VALUES (9223372036854775807)");
17+
var_dump($mysqli->insert_id);
18+
$mysqli->query("INSERT INTO foo VALUES (0)");
19+
var_dump($mysqli->insert_id);
20+
?>
21+
--EXPECT--
22+
string(19) "9223372036854775807"
23+
string(19) "9223372036854775808"

0 commit comments

Comments
 (0)