Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQLi uses unsupported format specifier on Windows #8267

Closed
cmb69 opened this issue Mar 29, 2022 · 0 comments
Closed

MySQLi uses unsupported format specifier on Windows #8267

cmb69 opened this issue Mar 29, 2022 · 0 comments

Comments

@cmb69
Copy link
Member

cmb69 commented Mar 29, 2022

Description

The following code:

<?php
$mysqli = new mysqli($host, $user, $pass, $db);
$mysqli->query("DROP TABLE IF EXISTS foo");
var_dump($mysqli->query("CREATE TABLE foo (id BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (id))"));
var_dump($mysqli->query("INSERT INTO foo VALUES (9223372036854775807)"));
var_dump($mysqli->insert_id);
var_dump($mysqli->query("INSERT INTO foo VALUES (0)"));
var_dump($mysqli->insert_id);

Resulted in this output:

string(5) "%I64u"
string(5) "%I64u"

But I expected this output instead:

string(19) "9223372036854775807"
string(19) "9223372036854775808"

The problem is that as of PHP 8.0.0, the %I* specifiers are no longer supported by our custom snprintf and spprintf implementations. This issue came up in php/doc-en#1483.


Well, actually I expected the following:

int(9223372036854775807)
string(19) "9223372036854775808"

but that off-by-one error is a minor issue, and fixing it would be a BC break.

PHP Version

PHP 8.0.17-dev

Operating System

Windows

@cmb69 cmb69 self-assigned this Mar 29, 2022
cmb69 added a commit to cmb69/php-src that referenced this issue Mar 29, 2022
Instead of using the unsupported `%I64u` and `%I64d` format specifiers
on Windows, we use the portable `PRIu64` and `PRId64` specifiers.

The `L64()` macro and the `my_longlong` typedef should be adapted as
well, as the `i64` literal suffix is still supported by MSVC, but using
`LL` or `ll` is recommended[1], and the standard `int64_t` is available
there anyway.  This is not urgent, though.

[1] <https://docs.microsoft.com/en-us/cpp/cpp/numeric-boolean-and-pointer-literals-cpp?view=msvc-170#integer-literals>
cmb69 added a commit that referenced this issue Apr 7, 2022
* PHP-8.0:
  Fix GH-8267: MySQLi uses unsupported format specifier on Windows
@cmb69 cmb69 closed this as completed in 7c702b7 Apr 7, 2022
cmb69 added a commit that referenced this issue Apr 7, 2022
* PHP-8.1:
  Fix GH-8267: MySQLi uses unsupported format specifier on Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@cmb69 and others