Skip to content

Commit 395bafe

Browse files
Formatting: Skip readonly properties in map_deep() to prevent fatal errors on PHP 8.1+.
1 parent 047ef80 commit 395bafe

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/wp-includes/formatting.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5145,6 +5145,13 @@ function map_deep( $value, $callback ) {
51455145
} elseif ( is_object( $value ) ) {
51465146
$object_vars = get_object_vars( $value );
51475147
foreach ( $object_vars as $property_name => $property_value ) {
5148+
if ( PHP_VERSION_ID >= 80100 ) {
5149+
$reflection_property = new ReflectionProperty( $value, $property_name );
5150+
if ( $reflection_property->isReadOnly() ) {
5151+
continue;
5152+
}
5153+
}
5154+
51485155
$value->$property_name = map_deep( $property_value, $callback );
51495156
}
51505157
} else {

0 commit comments

Comments
 (0)