summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2021-02-05 13:11:22 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2021-02-05 13:12:03 +0100
commit4be5b4aa25e17e5ab88e8002d4c5aaacc7fc1cf1 (patch)
treee49c22212393fa71c2b88a02b3578e8cca759b61
parent0c6ff5eafa360cf49ed93082e214552fbcb2d899 (diff)
parent3f8d21b9226493365cbb9f913322f5da6965c974 (diff)
downloadphp-git-4be5b4aa25e17e5ab88e8002d4c5aaacc7fc1cf1.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #74779: x() and y() truncating floats to integers
-rw-r--r--NEWS3
-rw-r--r--ext/mysqli/tests/bug74779.phpt42
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c2
3 files changed, 46 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index cbcc6d8839..3cb8d11174 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ PHP NEWS
. Fixed bug #53251 (bindtextdomain with null dir doesn't return old value).
(cmb)
+- MySQLi:
+ . Fixed bug #74779 (x() and y() truncating floats to integers). (cmb)
+
- Opcache:
. Fixed bug #80634 (write_property handler of internal classes is skipped on
preloaded JITted code). (Dmitry)
diff --git a/ext/mysqli/tests/bug74779.phpt b/ext/mysqli/tests/bug74779.phpt
new file mode 100644
index 0000000000..88e658ef61
--- /dev/null
+++ b/ext/mysqli/tests/bug74779.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Bug #74779 (x() and y() truncating floats to integers)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) die('skip locale not available');
+?>
+--FILE--
+<?php
+require_once("connect.inc");
+
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+}
+
+if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) {
+ echo "[002] Cannot set locale\n";
+}
+
+if (!$link->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true)) {
+ printf("[003] [%d] %s\n", $link->errno, $link->error);
+}
+
+if (!$result = $link->query("SELECT Y(Point(56.7, 53.34))")) {
+ printf("[004] [%d] %s\n", $link->errno, $link->error);
+}
+
+if (!$array = $result->fetch_array(MYSQLI_ASSOC)) {
+ printf("[005] [%d] %s\n", $link->errno, $link->error);
+}
+
+var_dump($array);
+
+mysqli_close($link);
+?>
+--EXPECT--
+array(1) {
+ ["Y(Point(56.7, 53.34))"]=>
+ float(53,34)
+}
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index 1fc2941e66..f98cb6c971 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -1667,7 +1667,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
zend_uchar save = *(p + len);
/* We have to make it ASCIIZ temporarily */
*(p + len) = '\0';
- ZVAL_DOUBLE(current_field, atof((char *) p));
+ ZVAL_DOUBLE(current_field, zend_strtod((char *) p, NULL));
*(p + len) = save;
}
#endif /* MYSQLND_STRING_TO_INT_CONVERSION */