Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .claude/CLAUDE.md

This file was deleted.

1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
9 changes: 9 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ PHP NEWS
- Core:
. Fixed incorrect internal pointer and foreach iterator positions when
compacting arrays with holes. (Weilin Du)
. Fix handling of references to typed properties during unserialization
of various internal classes. (ndossche, timwolla)

- Date:
. Fix unserialization of Time\Duration. (timwolla)

- DOM:
. Fixed use-after-free when re-constructing a DOMXPath whose php:function
Expand Down Expand Up @@ -34,6 +39,10 @@ PHP NEWS
. Fixed bug GH-23385 (SplDoublyLinkedList::serialize() use-after-free when
__serialize() removes an element). (David Carlier)

- Standard:
. Fixed bug #60110 (fclose(), file_put_contents(), copy() do not return false
properly). (Jakub Zelenka, Ilija Tovilo)


10 Sep 2026, PHP 8.6.0beta3

Expand Down
6 changes: 6 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ PHP 8.6 UPGRADE NOTES
========================================

- Core:
. By-reference foreach loops may now visit previously skipped elements
after array compaction. Internal pointers on deleted elements now move
to the next surviving element during copy-on-write.
. ??/empty() on a magic property no longer call __get() when __isset()
has materialized the property by writing into the property table.
The freshly-written value is returned directly. isset() is unaffected.
Expand Down Expand Up @@ -730,6 +733,9 @@ PHP 8.6 UPGRADE NOTES
directive when $details is true. It holds the built-in default value of the
directive (or null if it has none), independent of values set in php.ini,
on the command line, or at runtime.
. fclose(), file_put_contents() and copy() now return false when flushing
or closing the stream fails. Previously such failures were silently
ignored.

- Zip:
. zip_entry_close() return type has been narrowed from bool to true. The
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ PHP 8.6 INTERNALS UPGRADE NOTES
instead of a zval*. Accordingly, zend_get_closure_this_ptr() now returns
that zend_object*, or NULL when the closure is unbound, instead of a
zval* that is IS_UNDEF when the closure is unbound.
. object_properties_load() now verifies that the given value is assignable
to typed properties. The check is performed in strict mode.

- Added:
. New zend_class_entry.ce_flags2 and zend_function.fn_flags2 fields were
Expand Down
54 changes: 46 additions & 8 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ ZEND_API void object_properties_load(zend_object *object, const HashTable *prope
zval *prop, tmp;
zend_string *key;
zend_long h;
const zend_property_info *property_info;
zend_property_info *property_info;

ZEND_HASH_FOREACH_KEY_VAL(properties, h, key, prop) {
if (key) {
Expand All @@ -1785,18 +1785,56 @@ ZEND_API void object_properties_load(zend_object *object, const HashTable *prope
if (property_info != ZEND_WRONG_PROPERTY_INFO &&
property_info &&
(property_info->flags & ZEND_ACC_STATIC) == 0) {
bool is_typed = ZEND_TYPE_IS_SET(property_info->type);

/* Mimick unserialize behaviour for virtual properties. */
if (UNEXPECTED(property_info->flags & ZEND_ACC_VIRTUAL)) {
zend_throw_error(NULL, "Cannot unserialize value for virtual property %s::$%s", ZSTR_VAL(object->ce->name), zend_get_unmangled_property_name(property_info->name));
return;
}

zval *slot = OBJ_PROP(object, property_info->offset);
if (UNEXPECTED((property_info->flags & ZEND_ACC_READONLY) && !Z_ISUNDEF_P(slot))) {
if (Z_PROP_FLAG_P(slot) & IS_PROP_REINITABLE) {
Z_PROP_FLAG_P(slot) &= ~IS_PROP_REINITABLE;
zval val;

if (is_typed) {
if (UNEXPECTED(Z_ISREF_P(prop))) {
/* Block taking a reference to a readonly property. */
if (UNEXPECTED(property_info->flags & ZEND_ACC_READONLY)) {
zend_readonly_property_indirect_modification_error(property_info);
return;
}
if (UNEXPECTED(!zend_verify_prop_assignable_by_ref(property_info, prop, /* strict */ true))) {
ZEND_ASSERT(EG(exception));
return;
}
ZVAL_COPY(&val, prop);
ZEND_REF_ADD_TYPE_SOURCE(Z_REF_P(&val), property_info);
} else {
zend_readonly_property_modification_error(property_info);
return;
/* Mimick zend_assign_to_typed_prop() by reporting the error before doing work. */
if (UNEXPECTED((property_info->flags & ZEND_ACC_READONLY)
&& !Z_ISUNDEF_P(slot)
&& !(Z_PROP_FLAG_P(slot) & IS_PROP_REINITABLE))) {
zend_readonly_property_modification_error(property_info);
return;
}

ZVAL_COPY(&val, prop);
if (UNEXPECTED(!zend_verify_property_type(property_info, &val, /* strict */ true))) {
zval_ptr_dtor(&val);
return;
}
}
if (UNEXPECTED(Z_ISREF_P(slot))
&& (ZEND_DEBUG || ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(slot)))) {
ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(slot), property_info);
}
} else {
ZVAL_COPY(&val, prop);
}

Z_PROP_FLAG_P(slot) &= ~IS_PROP_REINITABLE;
zval_ptr_dtor(slot);
ZVAL_COPY_VALUE(slot, prop);
zval_add_ref(slot);
ZVAL_COPY_VALUE(slot, &val);
if (object->properties) {
ZVAL_INDIRECT(&tmp, slot);
zend_hash_update(object->properties, key, &tmp);
Expand Down
9 changes: 3 additions & 6 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ ZEND_METHOD(Exception, getCode)
ZEND_PARSE_PARAMETERS_NONE();

prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_CODE);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY_DEREF(return_value, prop);
}
/* }}} */

Expand All @@ -475,8 +474,7 @@ ZEND_METHOD(Exception, getTrace)
ZEND_PARSE_PARAMETERS_NONE();

prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_TRACE);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY_DEREF(return_value, prop);
}
/* }}} */

Expand All @@ -488,8 +486,7 @@ ZEND_METHOD(ErrorException, getSeverity)
ZEND_PARSE_PARAMETERS_NONE();

prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_SEVERITY);
ZVAL_DEREF(prop);
ZVAL_COPY(return_value, prop);
ZVAL_COPY_DEREF(return_value, prop);
}
/* }}} */

Expand Down
3 changes: 1 addition & 2 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,7 @@ static zend_never_inline zval* zend_assign_to_typed_prop(const zend_property_inf
}
}

ZVAL_DEREF(value);
ZVAL_COPY(&tmp, value);
ZVAL_COPY_DEREF(&tmp, value);

if (UNEXPECTED(!i_zend_verify_property_type(info, &tmp, EX_USES_STRICT_TYPES()))) {
zval_ptr_dtor(&tmp);
Expand Down
Loading