Skip to content

Commit 446d189

Browse files
committed
Merge branch 'PHP-7.4' of git.php.net:/php-src into PHP-7.4
* 'PHP-7.4' of git.php.net:/php-src: Fix #79557: extension_dir = ./ext now use current directory for base Fix #79596: MySQL FLOAT truncates to int some locales [ci skip] Fix NEWS
2 parents ccd41e0 + 8c6d006 commit 446d189

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

ext/mysqlnd/mysql_float_to_double.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
/*
3333
* Convert from a 4-byte float to a 8-byte decimal by first converting
34-
* the float to a string, and then the string to a double.
34+
* the float to a string (ignoring localization), and then the string to a double.
3535
* The decimals argument specifies the precision of the output. If decimals
3636
* is less than zero, then a gcvt(3) like logic is used with the significant
3737
* digits set to FLT_DIG i.e. 6.
@@ -42,7 +42,7 @@ static inline double mysql_float_to_double(float fp4, int decimals) {
4242
if (decimals < 0) {
4343
php_gcvt(fp4, FLT_DIG, '.', 'e', num_buf);
4444
} else {
45-
sprintf(num_buf, "%.*f", decimals, fp4);
45+
snprintf(num_buf, MAX_CHAR_BUF_LEN, "%.*F", decimals, fp4);
4646
}
4747

4848
return zend_strtod(num_buf, NULL);

ext/pdo_mysql/tests/bug79596.phpt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #79596 (MySQL FLOAT truncates to int some locales)
3+
--SKIPIF--
4+
<?php
5+
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
6+
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
MySQLPDOTest::skip();
8+
if (!setlocale(LC_ALL, 'de_DE', 'de-DE')) die('skip German locale not available');
9+
?>
10+
--FILE--
11+
<?php
12+
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
13+
14+
setlocale(LC_ALL, 'de_DE', 'de-DE');
15+
16+
$pdo = MySQLPDOTest::factory();
17+
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
18+
$pdo->query('CREATE TABLE bug79596 (broken FLOAT(2,1))');
19+
$pdo->query('INSERT INTO bug79596 VALUES(4.9)');
20+
var_dump($pdo->query('SELECT broken FROM bug79596')->fetchColumn(0));
21+
?>
22+
--CLEAN--
23+
<?php
24+
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
25+
26+
$pdo = MySQLPDOTest::factory();
27+
$pdo->exec("DROP TABLE IF EXISTS bug79596");
28+
?>
29+
--EXPECT--
30+
float(4,9)

win32/winutil.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,13 @@ PHP_WINUTIL_API char *php_win32_get_username(void)
440440

441441
static zend_always_inline BOOL is_compatible(const char *name, BOOL is_smaller, char *format, char **err)
442442
{/*{{{*/
443-
PLOADED_IMAGE img = ImageLoad(name, NULL);
443+
/* work around ImageLoad() issue */
444+
char *name_stripped = name;
445+
if (name[0] == '.' && IS_SLASH(name[1])) {
446+
name_stripped += 2;
447+
}
448+
449+
PLOADED_IMAGE img = ImageLoad(name_stripped, NULL);
444450

445451
if (!img) {
446452
DWORD _err = GetLastError();

0 commit comments

Comments
 (0)