|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67357 Cloned NumberFormatter object loses attributes
Submitted: 2014-05-29 04:32 UTC Modified: 2015-01-19 08:01 UTC
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: roman dot kulish at gmail dot com Assigned: stas (profile)
Status: Closed Package: intl (PECL)
PHP Version: 5.5.12 OS: all
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.
Bug Type:
From: roman dot kulish at gmail dot com
New email:
PHP Version: OS:


 [2014-05-29 04:32 UTC] roman dot kulish at gmail dot com
It seems that a cloned NumberFormatter object loses attributes set to the original object.

I tried setting attributes in both NumberFormatter::setTextAttribute() and NumberFormatter::setAttribute() and they were not transferred to the cloned object.

It may affect other intl object that has custom attributes.

Test script:
$fmt = NumberFormatter::create('en', NumberFormatter::DURATION);
$fmt->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%with-words");

$fmt_clone = clone $fmt;

var_dump($fmt->getTextAttribute(NumberFormatter::DEFAULT_RULESET), $fmt_clone->getTextAttribute(NumberFormatter::DEFAULT_RULESET));

$fmt = NumberFormatter::create('en', NumberFormatter::DECIMAL);
$fmt->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);

$fmt_clone = clone $fmt;

var_dump($fmt->getAttribute(NumberFormatter::FRACTION_DIGITS), $fmt_clone->getTextAttribute(NumberFormatter::FRACTION_DIGITS));

Expected result:
string(9) "%with-words"
string(9) "%with-words"

Actual result:
string(11) "%with-words"
string(9) "%duration"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-07 06:30 UTC]
Looks like this is an upstream library problem - same happens in pure C when using unum_clone. Filed with ICU, let's see what they say.
 [2014-07-07 06:41 UTC]
-Status: Open +Status: Analyzed
 [2015-01-17 13:57 UTC]
The upstream bug was updated as a duplicate of

"..this appears to be fixed as of v53.1 so I assume you are running an older version? Upgrading to that release should solve your issue."
 [2015-01-19 08:01 UTC]
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: stas
 [2015-01-19 08:01 UTC]
Works for me now with ICU 54. So closing it, please reopen if still happens on ICU 54+.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Dec 05 09:01:27 2023 UTC