Formatting: Skip readonly properties in map_deep() to prevent fatal errors on PHP 8.1+#11334
Formatting: Skip readonly properties in map_deep() to prevent fatal errors on PHP 8.1+#11334himanshupathak95 wants to merge 1 commit intoWordPress:trunkfrom
map_deep() to prevent fatal errors on PHP 8.1+#11334Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…rrors on PHP 8.1+.
321b175 to
395bafe
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Trac ticket: https://core.trac.wordpress.org/ticket/60355
On PHP 8.1+, passing an object with
readonlyproperties throughmap_deep()causes a fatal error because the function attempts to reassign every property after applying the callback.This affects any code path that stores objects in metadata, since
update_metadata()→wp_unslash()→stripslashes_deep()callsmap_deep()internally.This PR adds a
PHP_VERSION_ID >= 80100guard insidemap_deep()that usesReflectionProperty::isReadOnly()to detect and skip readonly properties.