php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74063 NumberFormatter fails after retrieval from session
Submitted: 2017-02-08 17:28 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: mrfellows at gmail dot com Assigned:
Status: Open Package: intl (PECL)
PHP Version: 7.0.15 OS: ubuntu 16.04.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mrfellows at gmail dot com
New email:
PHP Version: OS:

 

 [2017-02-08 17:28 UTC] mrfellows at gmail dot com
Description:
------------
A NumberFormatter instance retrieved from the session generates an 

'Found unconstructed NumberFormatter: U_ILLEGAL_ARGUMENT_ERROR'

on calling ::format(). 

The code snippet below can be run from the in-built webserver.  The second time the page is requested (within a session), the above error is reported.

Test script:
---------------
session_start();

if(isset($_SESSION["currencyFormatter"])){
    $formatter = $_SESSION["currencyFormatter"];
    echo "loaded formatter from session\n";
} else {
    echo "no formatter on session\n";
    $formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
    $_SESSION["currencyFormatter"] = $formatter;
}

var_dump($formatter->format(123, NumberFormatter::CURRENCY));
if(intl_is_failure($formatter->getErrorCode())) {
    echo "\n" . $formatter->getErrorMessage();
}

session_commit();

Expected result:
----------------
First request:

no formatter on session
string '£123.00' (length=8)

Subsequent requests:

loaded formatter from session
string '£123.00' (length=8)

Actual result:
--------------
First request:

no formatter on session
string '£123.00' (length=8)

Subsequent requests:

loaded formatter from session
boolean false
Found unconstructed NumberFormatter: U_ILLEGAL_ARGUMENT_ERROR

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-09 15:01 UTC] andrew dot nester dot dev at gmail dot com
Thanks for pointing out this issue! Just added PR fixing this.
 [2017-03-27 13:06 UTC] testingteam2 at gmail dot com
I am using Magento 2 so enable Intl module.
When enable extension=php_intl.dll 
Then generate error "Fatal error: Class 'IntlDateFormatter' not found"

Check by command line, then giving warning
"PHP Warning:  PHP Startup: Unable to load dynamic library 'E:\xampp\php\ext\php_
intl.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0 "

So please suggest me how to resolve it.
Thanks.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 23:01:24 2019 UTC