Commit 13f75a02aaa for php
commit 13f75a02aaa04fb82cfec4c3560dbb0f94b4e99c
Merge: c41c7227b84 18652e6f4b7
Author: ndossche <7771979+ndossche@users.noreply.github.com>
Date: Mon Nov 23 22:00:16 2026 +0100
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
ext/reflection: Don't call destructor when constructor is not public in newInstance(Args)()
diff --cc NEWS
index 41b530a58cf,fc0c29d71a3..5975696d930
--- a/NEWS
+++ b/NEWS
@@@ -182,7 -153,23 +182,9 @@@ PH
. Fixed ReflectionMethod::getClosure() returning a closure for abstract
methods, which crashed when called for the ones of internal classes.
(Nicolas Grekas)
+ . Don't call destructor when constructor is not public in newInstance(Args)().
+ (ndossche)
-- SNMP:
- . Fixed snmp3_set() citing the wrong argument number for an invalid $timeout
- or $retries. (lacatoire)
- . Fixed the procedural snmp functions citing the wrong argument number for an
- invalid $hostname or $community. (lacatoire)
-
-- SOAP:
- . Fixed bug GH-25267 (NULL dereference in to_xml_any() with integer key).
- (lazerg)
-
-- Sockets:
- . Fixed bug GH-25530 (socket_last_error() without a socket returns an error
- from a previous request). (Artem Ukrainskiy)
-
- Session:
. Fixed session upload progress to respect session.use_only_cookies.
(jorgsowa)
diff --cc ext/reflection/php_reflection.c
index 912be937a4b,feb0c14cb7d..618be5a40f6
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@@ -4999,8 -5178,13 +4999,9 @@@ ZEND_METHOD(ReflectionClass, newInstanc
/* Run the constructor if there is one */
if (constructor) {
- zval *params;
- int num_args;
- HashTable *named_params;
-
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name));
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %pS", ce->name);
+ zend_object_store_ctor_failed(Z_OBJ_P(return_value));
zval_ptr_dtor(return_value);
RETURN_NULL();
}
@@@ -5075,7 -5257,8 +5076,8 @@@ ZEND_METHOD(ReflectionClass, newInstanc
/* Run the constructor if there is one */
if (constructor) {
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) {
- zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name));
+ zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %pS", ce->name);
+ zend_object_store_ctor_failed(Z_OBJ_P(return_value));
zval_ptr_dtor(return_value);
RETURN_NULL();
}