diff --git a/NEWS b/NEWS index cf57d0a36b676..68e7df9d84f7f 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,8 @@ PHP NEWS . Bumped ICU requirement to ICU >= 57.1. (cmb) . IntlDateFormatter::setTimeZone()/datefmt_set_timezone() throws an exception with uninitialised classes or clone failure. (David Carlier) + . Added DECIMAL_COMPACT_SHORT/DECIMAL_COMPACT_LONG for NumberFormatter class. + (BogdanUngureanu) - MySQLi: . Fixed bugs GH-17900 and GH-8084 (calling mysqli::__construct twice). diff --git a/UPGRADING b/UPGRADING index 4129c7349444a..21cf4d3062df7 100644 --- a/UPGRADING +++ b/UPGRADING @@ -291,6 +291,10 @@ PHP 8.5 UPGRADE NOTES . CURLINFO_HTTPAUTH_USED. . CURLINFO_PROXYAUTH_USED. +- Intl: + . DECIMAL_COMPACT_SHORT. + . DECIMAL_COMPACT_LONG. + - POSIX: . POSIX_SC_OPEN_MAX. diff --git a/Zend/tests/lazy_objects/gh17941.phpt b/Zend/tests/lazy_objects/gh17941.phpt new file mode 100644 index 0000000000000..6af6355b99573 --- /dev/null +++ b/Zend/tests/lazy_objects/gh17941.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-17941 (Stack-use-after-return with lazy objects and hooks) +--FILE-- + $this->prop; set($x) => $this->prop = $x;} +} + +$rc = new ReflectionClass(SubClass::class); +$obj = $rc->newLazyProxy(function ($object) { + echo "init\n"; + return new SubClass; +}); + +function foo(SubClass $x) { + $x->prop = 1; + var_dump($x->prop); +} + +foo($obj); + +?> +--EXPECT-- +init +int(1) diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 56bea75922673..de3c0a1fd5310 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -1198,6 +1198,11 @@ lazy_init:; variable_ptr = zend_std_write_property(zobj, name, &backup, cache_slot); zval_ptr_dtor(&backup); + + if (variable_ptr == &backup) { + variable_ptr = value; + } + return variable_ptr; } /* }}} */ diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 6bcee1bc23e15..652ef22e506ab 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -367,13 +367,14 @@ static zend_always_inline const dom_prop_handler *dom_get_prop_handler(const dom if (obj->prop_handler != NULL) { if (cache_slot && *cache_slot == obj->prop_handler) { - hnd = *(cache_slot + 1); + hnd = cache_slot[1]; } if (!hnd) { hnd = zend_hash_find_ptr(obj->prop_handler, name); if (cache_slot) { - *cache_slot = obj->prop_handler; - *(cache_slot + 1) = (void *) hnd; + cache_slot[0] = obj->prop_handler; + cache_slot[1] = (void *) hnd; + cache_slot[2] = NULL; } } } diff --git a/ext/dom/tests/gh17991.phpt b/ext/dom/tests/gh17991.phpt new file mode 100644 index 0000000000000..4fc2c5b4ec1eb --- /dev/null +++ b/ext/dom/tests/gh17991.phpt @@ -0,0 +1,28 @@ +--TEST-- +GH-17991 (Assertion failure dom_attr_value_write) +--EXTENSIONS-- +dom +--FILE-- +value = new Test); +} +$box = new Box(); +test($box); +test($attr); +?> +--EXPECTF-- +object(Test)#%d (0) { +} + +Fatal error: Uncaught TypeError: Cannot assign Test to property DOMAttr::$value of type string in %s:%d +Stack trace: +#0 %s(%d): test(Object(DOMAttr)) +#1 {main} + thrown in %s on line %d diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 0bbf077a52500..9392db60b31aa 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -3721,7 +3721,7 @@ PHP_FUNCTION(imageconvolution) } for (i=0; i<3; i++) { - if ((var = zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i))) != NULL && Z_TYPE_P(var) == IS_ARRAY) { + if ((var = zend_hash_index_find_deref(Z_ARRVAL_P(hash_matrix), (i))) != NULL && Z_TYPE_P(var) == IS_ARRAY) { if (zend_hash_num_elements(Z_ARRVAL_P(var)) != 3 ) { zend_argument_value_error(2, "must be a 3x3 array, matrix[%d] only has %d elements", i, zend_hash_num_elements(Z_ARRVAL_P(var))); RETURN_THROWS(); @@ -4034,7 +4034,7 @@ PHP_FUNCTION(imageaffine) } for (i = 0; i < nelems; i++) { - if ((zval_affine_elem = zend_hash_index_find(Z_ARRVAL_P(z_affine), i)) != NULL) { + if ((zval_affine_elem = zend_hash_index_find_deref(Z_ARRVAL_P(z_affine), i)) != NULL) { switch (Z_TYPE_P(zval_affine_elem)) { case IS_LONG: case IS_DOUBLE: @@ -4200,7 +4200,7 @@ PHP_FUNCTION(imageaffinematrixconcat) } for (i = 0; i < 6; i++) { - if ((tmp = zend_hash_index_find(Z_ARRVAL_P(z_m1), i)) != NULL) { + if ((tmp = zend_hash_index_find_deref(Z_ARRVAL_P(z_m1), i)) != NULL) { switch (Z_TYPE_P(tmp)) { case IS_LONG: case IS_DOUBLE: @@ -4213,7 +4213,7 @@ PHP_FUNCTION(imageaffinematrixconcat) } } - if ((tmp = zend_hash_index_find(Z_ARRVAL_P(z_m2), i)) != NULL) { + if ((tmp = zend_hash_index_find_deref(Z_ARRVAL_P(z_m2), i)) != NULL) { switch (Z_TYPE_P(tmp)) { case IS_LONG: case IS_DOUBLE: diff --git a/ext/gd/tests/gh17984.phpt b/ext/gd/tests/gh17984.phpt new file mode 100644 index 0000000000000..c46c455799e0f --- /dev/null +++ b/ext/gd/tests/gh17984.phpt @@ -0,0 +1,44 @@ +--TEST-- +GH-17984: array of references handling +--EXTENSIONS-- +gd +--FILE-- + +--EXPECT-- +object(GdImage)#2 (0) { +} +array(6) { + [0]=> + float(2028) + [1]=> + float(46) + [2]=> + float(138) + [3]=> + float(4) + [4]=> + float(233) + [5]=> + float(7) +} +bool(true) +bool(true) +bool(true) diff --git a/ext/intl/formatter/formatter.stub.php b/ext/intl/formatter/formatter.stub.php index e335698688d64..4445005c41705 100644 --- a/ext/intl/formatter/formatter.stub.php +++ b/ext/intl/formatter/formatter.stub.php @@ -11,6 +11,10 @@ class NumberFormatter public const int PATTERN_DECIMAL = UNKNOWN; /** @cvalue UNUM_DECIMAL */ public const int DECIMAL = UNKNOWN; + /** @cvalue UNUM_DECIMAL_COMPACT_SHORT */ + public const int DECIMAL_COMPACT_SHORT = UNKNOWN; + /** @cvalue UNUM_DECIMAL_COMPACT_LONG */ + public const int DECIMAL_COMPACT_LONG = UNKNOWN; /** @cvalue UNUM_CURRENCY */ public const int CURRENCY = UNKNOWN; /** @cvalue UNUM_PERCENT */ diff --git a/ext/intl/formatter/formatter_arginfo.h b/ext/intl/formatter/formatter_arginfo.h index 0e3d8b797e721..c7fd28c3a9f77 100644 --- a/ext/intl/formatter/formatter_arginfo.h +++ b/ext/intl/formatter/formatter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: caaa6ff408bfd88ec9bb998ffd753f4de971ccff */ + * Stub hash: 05ab9fb3ba33163b2100e2773d70f67e110ecefc */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter___construct, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0) @@ -137,6 +137,18 @@ static zend_class_entry *register_class_NumberFormatter(void) zend_declare_typed_class_constant(class_entry, const_DECIMAL_name, &const_DECIMAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_DECIMAL_name); + zval const_DECIMAL_COMPACT_SHORT_value; + ZVAL_LONG(&const_DECIMAL_COMPACT_SHORT_value, UNUM_DECIMAL_COMPACT_SHORT); + zend_string *const_DECIMAL_COMPACT_SHORT_name = zend_string_init_interned("DECIMAL_COMPACT_SHORT", sizeof("DECIMAL_COMPACT_SHORT") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_DECIMAL_COMPACT_SHORT_name, &const_DECIMAL_COMPACT_SHORT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_DECIMAL_COMPACT_SHORT_name); + + zval const_DECIMAL_COMPACT_LONG_value; + ZVAL_LONG(&const_DECIMAL_COMPACT_LONG_value, UNUM_DECIMAL_COMPACT_LONG); + zend_string *const_DECIMAL_COMPACT_LONG_name = zend_string_init_interned("DECIMAL_COMPACT_LONG", sizeof("DECIMAL_COMPACT_LONG") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_DECIMAL_COMPACT_LONG_name, &const_DECIMAL_COMPACT_LONG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_DECIMAL_COMPACT_LONG_name); + zval const_CURRENCY_value; ZVAL_LONG(&const_CURRENCY_value, UNUM_CURRENCY); zend_string *const_CURRENCY_name = zend_string_init_interned("CURRENCY", sizeof("CURRENCY") - 1, 1); diff --git a/ext/intl/tests/formatter_format_decimal_compact.phpt b/ext/intl/tests/formatter_format_decimal_compact.phpt new file mode 100644 index 0000000000000..2c78f8787e0f4 --- /dev/null +++ b/ext/intl/tests/formatter_format_decimal_compact.phpt @@ -0,0 +1,57 @@ +--TEST-- +numfmt_format_currency() icu >= 4.8 +--EXTENSIONS-- +intl +--FILE-- + +--EXPECTF-- +en_UK: short = 1.2M +en_UK: long = 1.2 million +en_US: short = 1.2M +en_US: long = 1.2 million +ru: short = 1,2 млн +ru: long = 1,2 миллиона +zh_CN: short = 123万 +zh_CN: long = 123万 +ro: short = 1,2 mil. +ro: long = 1,2 milioane +uk: short = 1,2 млн +uk: long = 1,2 мільйона +en: short = 1.2M +en: long = 1.2 million +bg: short = 1,2 млн. +bg: long = 1,2 милиона \ No newline at end of file