Skip to content

Commit

Permalink
Fixed bug #81019
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed May 17, 2021
1 parent c446d68 commit 0bff67c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ PHP NEWS
. Fixed bug #81032 (GD install is affected by external libgd installation).
(Flavio Heleno, cmb)

- Intl:
. Fixed bug #81019 (Unable to clone NumberFormatter after failed parse()).
(Nikita)

- MBString:
. Fixed bug #81011 (mb_convert_encoding removes references from arrays). (cmb)

Expand Down
1 change: 1 addition & 0 deletions ext/intl/dateformat/dateformat_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ zend_object *IntlDateFormatter_object_clone(zend_object *object)
zend_object *new_obj;

dfo = php_intl_dateformatter_fetch_object(object);
intl_error_reset(INTL_DATA_ERROR_P(dfo));

new_obj = IntlDateFormatter_ce_ptr->create_object(object->ce);
new_dfo = php_intl_dateformatter_fetch_object(new_obj);
Expand Down
2 changes: 2 additions & 0 deletions ext/intl/formatter/formatter_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ zend_object *NumberFormatter_object_clone(zend_object *object)
zend_object *new_obj;

nfo = php_intl_number_format_fetch_object(object);
intl_error_reset(INTL_DATA_ERROR_P(nfo));

new_obj = NumberFormatter_ce_ptr->create_object(object->ce);
new_nfo = php_intl_number_format_fetch_object(new_obj);
/* clone standard parts */
Expand Down
2 changes: 2 additions & 0 deletions ext/intl/msgformat/msgformat_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ zend_object *MessageFormatter_object_clone(zend_object *object)
zend_object *new_obj;

mfo = php_intl_messageformatter_fetch_object(object);
intl_error_reset(INTL_DATA_ERROR_P(mfo));

new_obj = MessageFormatter_ce_ptr->create_object(object->ce);
new_mfo = php_intl_messageformatter_fetch_object(new_obj);
/* clone standard parts */
Expand Down
21 changes: 21 additions & 0 deletions ext/intl/tests/bug81019.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Bug #81019: Unable to clone NumberFormatter after failed parse()
--FILE--
<?php

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

$datefmt = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
$datefmt->parse('abc');
$datefmt2 = clone $datefmt;

$msgfmt = new MessageFormatter('en_US', '{0,number,integer}');
$msgfmt->parse('abc');
$msgfmt2 = clone $msgfmt;

?>
===DONE===
--EXPECT--
===DONE===

0 comments on commit 0bff67c

Please sign in to comment.