[php-src] Issue #8351: explicit `__construct` call for \DateTimeImmutable object would break immutable

From: Date: Wed, 13 Apr 2022 17:07:17 +0000
Subject: [php-src] Issue #8351: explicit `__construct` call for \DateTimeImmutable object would break immutable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240937@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8351 Comment Author: cmb69 >That does not appear to help with internal classes. The [constructor's implementation](https://github.com/php/php-src/blob/8233e061091bc442009529d49e4718ea15454e57/Zend/zend_attributes.c#L112) circumvents the readonly protection. Instead of just replacing the zval, the write_property handler of the object would need to be called. <details> <summary>diff</summary> ````diff Zend/zend_attributes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index 9f7b8f0144..f060e9d23c 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -109,7 +109,9 @@ ZEND_METHOD(SensitiveParameterValue, __construct) Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); - ZVAL_COPY(OBJ_PROP_NUM(Z_OBJ_P(ZEND_THIS), 0), value); + zend_string *name = zend_string_init("value", sizeof("value")-1, 0); + Z_OBJ_P(ZEND_THIS)->handlers->write_property(Z_OBJ_P(ZEND_THIS), name, value, NULL); + zend_string_release(name); } ZEND_METHOD(SensitiveParameterValue, getValue) ```` </details>

« previous php.bugs (#240937) next »