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: 2020-01-26 16:04 UTC
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: Verified Package: intl (PECL)
PHP Version: 7.0.15 OS: ubuntu 16.04.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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.
 [2020-01-26 16:04 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-01-26 16:04 UTC] cmb@php.net
I can confirm this issue; however, it is not related to sessions
in particular, but rather that unserialization of NumberFormatter
instances is not (yet) supported.

Since there is no agreed upon solution how to do this
unserialization, it seems to be sensible to disallow serialization
in the first place for now.
 [2020-01-26 16:06 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #74063: NumberFormatter fails after retrieval from session
On GitHub:  https://github.com/php/php-src/pull/5116
Patch:      https://github.com/php/php-src/pull/5116.patch
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jan 26 20:01:25 2020 UTC