Skip to content

Commit 3b08b42

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #74779: x() and y() truncating floats to integers
2 parents ce79d94 + 4be5b4a commit 3b08b42

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

ext/mysqli/tests/bug74779.phpt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug #74779 (x() and y() truncating floats to integers)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifconnectfailure.inc');
7+
if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) die('skip locale not available');
8+
?>
9+
--FILE--
10+
<?php
11+
require_once("connect.inc");
12+
13+
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
14+
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
15+
$host, $user, $db, $port, $socket);
16+
}
17+
18+
if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) {
19+
echo "[002] Cannot set locale\n";
20+
}
21+
22+
if (!$link->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true)) {
23+
printf("[003] [%d] %s\n", $link->errno, $link->error);
24+
}
25+
26+
if (!$result = $link->query("SELECT Y(Point(56.7, 53.34))")) {
27+
printf("[004] [%d] %s\n", $link->errno, $link->error);
28+
}
29+
30+
if (!$array = $result->fetch_array(MYSQLI_ASSOC)) {
31+
printf("[005] [%d] %s\n", $link->errno, $link->error);
32+
}
33+
34+
var_dump($array);
35+
36+
mysqli_close($link);
37+
?>
38+
--EXPECT--
39+
array(1) {
40+
["Y(Point(56.7, 53.34))"]=>
41+
float(53,34)
42+
}

ext/mysqlnd/mysqlnd_wireprotocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fiel
16531653
zend_uchar save = *(p + len);
16541654
/* We have to make it ASCIIZ temporarily */
16551655
*(p + len) = '\0';
1656-
ZVAL_DOUBLE(current_field, atof((char *) p));
1656+
ZVAL_DOUBLE(current_field, zend_strtod((char *) p, NULL));
16571657
*(p + len) = save;
16581658
} else {
16591659
ZVAL_STRINGL_FAST(current_field, (char *)p, len);

0 commit comments

Comments
 (0)