php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81019 Unable to clone NumberFormatter after failed parse()
Submitted: 2021-05-08 03:31 UTC Modified: 2021-05-17 14:17 UTC
From: corey dot taylor dot fl at gmail dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 8.0.6 OS:
Private report: No CVE-ID: None
 [2021-05-08 03:31 UTC] corey dot taylor dot fl at gmail dot com
Description:
------------
After calling `NumberFormatter::parse()` with an invalid string, cloning the NumberFormatter instance throws a Fatal Error:

$format = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
$format->parse('abc');
clone $format;

Fatal error: Uncaught Exception: Failed to clone NumberFormatter object

https://3v4l.org/XGVWZ

This seems to only occur with PHP 8.0+. Since `parse()` returns false on error, I wouldn't expect it to invalidate the object.

I was not sure what category this bug report falls under.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-08 03:34 UTC] corey dot taylor dot fl at gmail dot com
-Summary: Unable to close NumberFormatter after failed parse() +Summary: Unable to clone NumberFormatter after failed parse()
 [2021-05-08 03:34 UTC] corey dot taylor dot fl at gmail dot com
Fixed title typo.
 [2021-05-09 11:57 UTC] cmb@php.net
-Package: Unknown/Other Function +Package: intl
 [2021-05-12 22:52 UTC] corey dot taylor dot fl at gmail dot com
Why doesn't this bug entry show up on the (all) bugs listing?
 [2021-05-17 14:17 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2021-05-17 14:17 UTC] nikic@php.net
> Why doesn't this bug entry show up on the (all) bugs listing?

I believe that's because intl is classified as a PECL package, not a PHP package.
 [2021-05-17 14:33 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/0bff67c0ab37067b67623766740e84440e933958
Log: Fixed bug #81019
 [2021-05-17 14:33 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jun 18 03:01:23 2021 UTC