Bug #79317 [Com]: opcache and setlocale issue

From: Date: Fri, 28 Feb 2020 12:55:01 +0000
Subject: Bug #79317 [Com]: opcache and setlocale issue
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225782@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79317&edit=1

 ID:                 79317
 Comment by:         j dot arnold at qaamgo dot com
 Reported by:        j dot arnold at qaamgo dot com
 Summary:            opcache and setlocale issue
 Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   OpenSuse 15.1
 PHP Version:        7.4.3
 Block user comment: N
 Private report:     N

 New Comment:

> and how does that justify different behavior with or wuthout opcache?

exactly, also with opcache the first call is float is correct with a "," and the second
call is incorrect with a "."


Previous Comments:
------------------------------------------------------------------------
[2020-02-28 12:42:59] bugreports at gmail dot com

> This is due to the fact that displaying floats are locale aware

and how does that justify different behavior with or wuthout opcache?

------------------------------------------------------------------------
[2020-02-28 12:32:44] girgias@php.net

This is due to the fact that displaying floats are locale aware.

------------------------------------------------------------------------
[2020-02-28 12:28:29] j dot arnold at qaamgo dot com

Description:
------------
When executing the code below with "?lang=de_DE", the first call will result in a float
with comma in the concatenated string. On the second call this will result in a float with a dot.

When disabling opcache the issue is gone and it is always a comma.
Also in php 7.3 this issue does not occure.

So it seems that opcache is ignoring the setlocale.

Test script:
---------------
class Test {
    function __construct() {
        // call https://domain.tld?lang=de_DE
        // first call will result in a float with COMMA in the concatenated string
        // second call will result in a float with DOT in the concatenated string

        if ($_GET['lang']) {
            setlocale(LC_ALL, $_GET['lang'] . '.utf-8');
        }

        $z = 0.5;
        $y = $z . ' invalidate cache for this class by changing something here: v1';
        echo 'Concatenated string: ' . $y . '<br />';
        echo 'Plain Variable: ';
        echo $z;
        echo '<br />';
        exit;
    }
}

$test = new Test();

Expected result:
----------------
The float will always be with ",".



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79317&edit=1


Thread (8 messages)

« previous php.bugs (#225782) next »