From 146848429605752e156a9f0ced4bfb079720d094 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 29 Jan 2020 16:18:46 +0100 Subject: [PATCH] Fix #74063: NumberFormatter fails after retrieval from session While it would be desireable to actually support unserialization of NumberFormatter instances, at least we should not allow serialization for now. We also remove some doubtful tests, which have been added[1] claiming that they would crash the intl extension, but apparently no fix has been applied, and the test cases have not been marked as XFAIL. [1] --- ext/intl/formatter/formatter_class.c | 3 ++ ext/intl/tests/bug74063.phpt | 17 +++++++ .../symfony_format_type_double_intl1.phpt | 30 ------------ .../symfony_format_type_double_intl2.phpt | 30 ------------ .../symfony_format_type_double_intl3.phpt | 30 ------------ .../symfony_format_type_double_intl4.phpt | 31 ------------ .../symfony_format_type_int32_intl1.phpt | 49 ------------------- .../symfony_format_type_int32_intl2.phpt | 33 ------------- .../symfony_format_type_int32_intl3.phpt | 32 ------------ .../symfony_format_type_int32_intl4.phpt | 30 ------------ .../symfony_format_type_int32_intl5.phpt | 30 ------------ .../symfony_format_type_int32_intl6.phpt | 32 ------------ .../symfony_format_type_int32_intl7.phpt | 32 ------------ .../symfony_format_type_int64_intl1.phpt | 30 ------------ .../symfony_format_type_int64_intl2.phpt | 30 ------------ .../symfony_format_type_int64_intl3.phpt | 30 ------------ .../symfony_format_type_int64_intl4.phpt | 30 ------------ .../symfony_format_type_int64_intl5.phpt | 30 ------------ .../symfony_format_type_int64_intl6.phpt | 30 ------------ .../symfony_format_type_int64_intl7.phpt | 30 ------------ .../symfony_format_type_int64_intl8.phpt | 30 ------------ 21 files changed, 20 insertions(+), 599 deletions(-) create mode 100644 ext/intl/tests/bug74063.phpt delete mode 100644 ext/intl/tests/symfony_format_type_double_intl1.phpt delete mode 100644 ext/intl/tests/symfony_format_type_double_intl2.phpt delete mode 100644 ext/intl/tests/symfony_format_type_double_intl3.phpt delete mode 100644 ext/intl/tests/symfony_format_type_double_intl4.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int32_intl1.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int32_intl2.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int32_intl3.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int32_intl4.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int32_intl5.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int32_intl6.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int32_intl7.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl1.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl2.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl3.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl4.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl5.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl6.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl7.phpt delete mode 100644 ext/intl/tests/symfony_format_type_int64_intl8.phpt diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c index 91efbed94e..d6c3493c8c 100644 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.c @@ -23,6 +23,7 @@ #include "formatter_attr.h" #include +#include "Zend/zend_interfaces.h" zend_class_entry *NumberFormatter_ce_ptr = NULL; static zend_object_handlers NumberFormatter_handlers; @@ -181,6 +182,8 @@ void formatter_register_class( void ) INIT_CLASS_ENTRY( ce, "NumberFormatter", NumberFormatter_class_functions ); ce.create_object = NumberFormatter_object_create; NumberFormatter_ce_ptr = zend_register_internal_class( &ce ); + NumberFormatter_ce_ptr->serialize = zend_class_serialize_deny; + NumberFormatter_ce_ptr->unserialize = zend_class_unserialize_deny; memcpy(&NumberFormatter_handlers, &std_object_handlers, sizeof(NumberFormatter_handlers)); diff --git a/ext/intl/tests/bug74063.phpt b/ext/intl/tests/bug74063.phpt new file mode 100644 index 0000000000..126c4cc523 --- /dev/null +++ b/ext/intl/tests/bug74063.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #74063 (NumberFormatter fails after retrieval from session) +--SKIPIF-- + +--FILE-- +getMessage(), PHP_EOL; +} +?> +--EXPECT-- +Serialization of 'NumberFormatter' is not allowed diff --git a/ext/intl/tests/symfony_format_type_double_intl1.phpt b/ext/intl/tests/symfony_format_type_double_intl1.phpt deleted file mode 100644 index 9a5c6b2a25..0000000000 --- a/ext/intl/tests/symfony_format_type_double_intl1.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #1 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - int(1) - [2]=> - string(1) "1" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_double_intl2.phpt b/ext/intl/tests/symfony_format_type_double_intl2.phpt deleted file mode 100644 index e5014c6f34..0000000000 --- a/ext/intl/tests/symfony_format_type_double_intl2.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #2 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(1.1) - [2]=> - string(3) "1.1" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_double_intl3.phpt b/ext/intl/tests/symfony_format_type_double_intl3.phpt deleted file mode 100644 index fbfd629b75..0000000000 --- a/ext/intl/tests/symfony_format_type_double_intl3.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #3 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - int(1) - [2]=> - string(7) "SFD1.00" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_double_intl4.phpt b/ext/intl/tests/symfony_format_type_double_intl4.phpt deleted file mode 100644 index b736c23dab..0000000000 --- a/ext/intl/tests/symfony_format_type_double_intl4.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeDoubleIntl #4 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_DOUBLE); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} -?> ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(1.1) - [2]=> - string(7) "SFD1.10" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int32_intl1.phpt b/ext/intl/tests/symfony_format_type_int32_intl1.phpt deleted file mode 100644 index 717414fc6f..0000000000 --- a/ext/intl/tests/symfony_format_type_int32_intl1.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #1 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT32); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - int(1) - [2]=> - string(1) "1" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int32_intl2.phpt b/ext/intl/tests/symfony_format_type_int32_intl2.phpt deleted file mode 100644 index 4b84ec1979..0000000000 --- a/ext/intl/tests/symfony_format_type_int32_intl2.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #2 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT32); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(1.1) - [2]=> - string(1) "1" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int32_intl3.phpt b/ext/intl/tests/symfony_format_type_int32_intl3.phpt deleted file mode 100644 index efe35dd8b0..0000000000 --- a/ext/intl/tests/symfony_format_type_int32_intl3.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #3 ---SKIPIF-- - ---FILE-- -format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}'); - -var_dump($unit_test_args); - -// execute the code from #testFormatTypeInt32Intl -try { - $unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(4) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(2147483648) - [2]=> - string(14) "-2,147,483,648" - [3]=> - string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range." -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int32_intl4.phpt b/ext/intl/tests/symfony_format_type_int32_intl4.phpt deleted file mode 100644 index 8f6ea7b0c0..0000000000 --- a/ext/intl/tests/symfony_format_type_int32_intl4.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #4 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT32); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - int(1) - [2]=> - string(7) "SFD1.00" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int32_intl5.phpt b/ext/intl/tests/symfony_format_type_int32_intl5.phpt deleted file mode 100644 index b9d302a12f..0000000000 --- a/ext/intl/tests/symfony_format_type_int32_intl5.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #5 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT32); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(1.1) - [2]=> - string(7) "SFD1.00" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int32_intl6.phpt b/ext/intl/tests/symfony_format_type_int32_intl6.phpt deleted file mode 100644 index b00f3f7ce9..0000000000 --- a/ext/intl/tests/symfony_format_type_int32_intl6.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #6 ---SKIPIF-- - ---FILE-- -format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}'); - -var_dump($unit_test_args); - -// execute the code from #testFormatTypeInt32Intl -try { - $unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(4) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(2147483648) - [2]=> - string(21) "(SFD2,147,483,648.00)" - [3]=> - string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range." -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int32_intl7.phpt b/ext/intl/tests/symfony_format_type_int32_intl7.phpt deleted file mode 100644 index 747074f090..0000000000 --- a/ext/intl/tests/symfony_format_type_int32_intl7.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt32Intl #7 ---SKIPIF-- - ---FILE-- -format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.";}'); - -var_dump($unit_test_args); - -// execute the code from #testFormatTypeInt32Intl -try { - $unit_test_args[0]->format($unit_test_args[1], \NumberFormatter::TYPE_INT32); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(4) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(-2147483649) - [2]=> - string(19) "SFD2,147,483,647.00" - [3]=> - string(83) "->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range." -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int64_intl1.phpt b/ext/intl/tests/symfony_format_type_int64_intl1.phpt deleted file mode 100644 index 01f5820911..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl1.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #1 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); - -echo "== didn't crash ==".PHP_EOL; - -?> ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - int(1) - [2]=> - string(1) "1" -} -== didn't crash == diff --git a/ext/intl/tests/symfony_format_type_int64_intl2.phpt b/ext/intl/tests/symfony_format_type_int64_intl2.phpt deleted file mode 100644 index f659ac373d..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl2.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #2 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(1.1) - [2]=> - string(1) "1" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int64_intl3.phpt b/ext/intl/tests/symfony_format_type_int64_intl3.phpt deleted file mode 100644 index e40b74775c..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl3.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #3 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(2147483648) - [2]=> - string(13) "2,147,483,648" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int64_intl4.phpt b/ext/intl/tests/symfony_format_type_int64_intl4.phpt deleted file mode 100644 index 8785b83c0a..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl4.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #4 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(-2147483649) - [2]=> - string(14) "-2,147,483,649" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int64_intl5.phpt b/ext/intl/tests/symfony_format_type_int64_intl5.phpt deleted file mode 100644 index 476e66b61e..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl5.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #5 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - int(1) - [2]=> - string(7) "SFD1.00" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int64_intl6.phpt b/ext/intl/tests/symfony_format_type_int64_intl6.phpt deleted file mode 100644 index 5c24fe9617..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl6.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #6 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(1.1) - [2]=> - string(7) "SFD1.00" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int64_intl7.phpt b/ext/intl/tests/symfony_format_type_int64_intl7.phpt deleted file mode 100644 index 27b5a79f24..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl7.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #7 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(2147483648) - [2]=> - string(19) "SFD2,147,483,648.00" -} -Found unconstructed NumberFormatter diff --git a/ext/intl/tests/symfony_format_type_int64_intl8.phpt b/ext/intl/tests/symfony_format_type_int64_intl8.phpt deleted file mode 100644 index d33395d6b3..0000000000 --- a/ext/intl/tests/symfony_format_type_int64_intl8.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Symfony StubNumberFormatterTest#testFormatTypeInt64Intl #8 ---SKIPIF-- - ---FILE-- -format($unit_test_args[1], \NumberFormatter::TYPE_INT64); -} catch (Error $exception) { - echo $exception->getMessage() . "\n"; -} ---EXPECT-- -array(3) { - [0]=> - object(NumberFormatter)#1 (0) { - } - [1]=> - float(-2147483649) - [2]=> - string(21) "(SFD2,147,483,649.00)" -} -Found unconstructed NumberFormatter -- 2.40.0