Skip to content

Commit 0bff67c

Browse files
committed
Fixed bug #81019
Before the zval -> zend_object migration, this code used macros like FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK, which internally clear the error. Now that they are no longer used, we need to manually clear the error.
1 parent c446d68 commit 0bff67c

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ PHP NEWS
2020
. Fixed bug #81032 (GD install is affected by external libgd installation).
2121
(Flavio Heleno, cmb)
2222

23+
- Intl:
24+
. Fixed bug #81019 (Unable to clone NumberFormatter after failed parse()).
25+
(Nikita)
26+
2327
- MBString:
2428
. Fixed bug #81011 (mb_convert_encoding removes references from arrays). (cmb)
2529

ext/intl/dateformat/dateformat_class.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ zend_object *IntlDateFormatter_object_clone(zend_object *object)
7777
zend_object *new_obj;
7878

7979
dfo = php_intl_dateformatter_fetch_object(object);
80+
intl_error_reset(INTL_DATA_ERROR_P(dfo));
8081

8182
new_obj = IntlDateFormatter_ce_ptr->create_object(object->ce);
8283
new_dfo = php_intl_dateformatter_fetch_object(new_obj);

ext/intl/formatter/formatter_class.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ zend_object *NumberFormatter_object_clone(zend_object *object)
6464
zend_object *new_obj;
6565

6666
nfo = php_intl_number_format_fetch_object(object);
67+
intl_error_reset(INTL_DATA_ERROR_P(nfo));
68+
6769
new_obj = NumberFormatter_ce_ptr->create_object(object->ce);
6870
new_nfo = php_intl_number_format_fetch_object(new_obj);
6971
/* clone standard parts */

ext/intl/msgformat/msgformat_class.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ zend_object *MessageFormatter_object_clone(zend_object *object)
6262
zend_object *new_obj;
6363

6464
mfo = php_intl_messageformatter_fetch_object(object);
65+
intl_error_reset(INTL_DATA_ERROR_P(mfo));
66+
6567
new_obj = MessageFormatter_ce_ptr->create_object(object->ce);
6668
new_mfo = php_intl_messageformatter_fetch_object(new_obj);
6769
/* clone standard parts */

ext/intl/tests/bug81019.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #81019: Unable to clone NumberFormatter after failed parse()
3+
--FILE--
4+
<?php
5+
6+
$fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
7+
$fmt->parse('abc');
8+
$fmt2 = clone $fmt;
9+
10+
$datefmt = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
11+
$datefmt->parse('abc');
12+
$datefmt2 = clone $datefmt;
13+
14+
$msgfmt = new MessageFormatter('en_US', '{0,number,integer}');
15+
$msgfmt->parse('abc');
16+
$msgfmt2 = clone $msgfmt;
17+
18+
?>
19+
===DONE===
20+
--EXPECT--
21+
===DONE===

0 commit comments

Comments
 (0)