Skip to content

Commit 4be5b4a

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

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ PHP NEWS
66
. Fixed bug #53251 (bindtextdomain with null dir doesn't return old value).
77
(cmb)
88

9+
- MySQLi:
10+
. Fixed bug #74779 (x() and y() truncating floats to integers). (cmb)
11+
912
- Opcache:
1013
. Fixed bug #80634 (write_property handler of internal classes is skipped on
1114
preloaded JITted code). (Dmitry)

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
@@ -1667,7 +1667,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
16671667
zend_uchar save = *(p + len);
16681668
/* We have to make it ASCIIZ temporarily */
16691669
*(p + len) = '\0';
1670-
ZVAL_DOUBLE(current_field, atof((char *) p));
1670+
ZVAL_DOUBLE(current_field, zend_strtod((char *) p, NULL));
16711671
*(p + len) = save;
16721672
}
16731673
#endif /* MYSQLND_STRING_TO_INT_CONVERSION */

0 commit comments

Comments
 (0)