mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-01 08:37:55 +02:00
50274fbc2b
The unknown use of unknown dynamic property within the `WP_List_Table` property magic methods is now deprecated. A descriptive deprecation notice is provided to alert developers to declare the property on the child class extending `WP_List_Table`. Changes in this commit: * Adds a deprecation notice to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods, i.e. to alert and inform developers when attempting to get/set/isset/unset a dynamic property. * Fixes `__get()` to explicitly returns `null` when attempting to get a dynamic property. * Removes returning the value when setting a declared property, as (a) unnecessary and (b) `__set()` should return `void` [https://www.php.net/manual/en/language.oop5.overloading.php#object.set per the PHP handbook]. * Adds unit tests for happy and unhappy paths. For backward compatibility, no changes are made to the internal declared properties listed in `$compat_fields` and accessed through the magic methods. For example: A child class uses a property named `$data` that is not declared / defined as a property on the child class. When getting its value, e.g. `$list_table->data`, the `WP_List_Table::__get()` magic method is invoked, the following deprecation notice thrown, and `null` returned: >The property `data` is not defined. Setting a dynamic (undefined) property is deprecated since version 6.4.0! Instead, define the property on the class. === Why not remove the magic methods, remove the `$compat_fields` property, and restore the properties `public`? tl;dr Backward compatibility. Several plugins, one of which has over 5M installs, add a property to the `$compat_fields` array. Removing the property would cause an `Undefined property` `Warning` (PHP 8) | `Notice` (PHP 7) to be thrown. Removing the associated code would change the functionality. === Why not limit the deprecation for PHP versions >= 8.2? tl;dr original design intent and inform The magic methods and `$compat_fields` property were added for one purpose: to continue providing external access to internal properties declared on `WP_List_Table`. They were not intended to be used for dynamic properties. Deprecating that unintended usage both alerts developers a change is needed in their child class and informs them what to change. References: * Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0. * A [https://www.youtube.com/live/vDZWepDQQVE?feature=share&t=10097 live open public working session] where these changes were discussed and agreed to. * [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties.] Related to #14579, #22234, #30891. Follow-up to [15491], [28493], [28521], [28524], [31146]. Props antonvlasenko, jrf, markjaquith, hellofromTonya, SergeyBiryukov, desrosj, peterwilsoncc, audrasjb, costdev, oglekler, jeffpaul. Fixes #58896. See #56034. Built from https://develop.svn.wordpress.org/trunk@56349 git-svn-id: http://core.svn.wordpress.org/trunk@55861 1a063a9b-81f0-0310-95a4-ce76da25c4cd |
||
---|---|---|
.. | ||
css | ||
images | ||
includes | ||
js | ||
maint | ||
network | ||
user | ||
about.php | ||
admin-ajax.php | ||
admin-footer.php | ||
admin-functions.php | ||
admin-header.php | ||
admin-post.php | ||
admin.php | ||
async-upload.php | ||
authorize-application.php | ||
comment.php | ||
contribute.php | ||
credits.php | ||
custom-background.php | ||
custom-header.php | ||
customize.php | ||
edit-comments.php | ||
edit-form-advanced.php | ||
edit-form-blocks.php | ||
edit-form-comment.php | ||
edit-link-form.php | ||
edit-tag-form.php | ||
edit-tags.php | ||
edit.php | ||
erase-personal-data.php | ||
export-personal-data.php | ||
export.php | ||
freedoms.php | ||
import.php | ||
index.php | ||
install-helper.php | ||
install.php | ||
link-add.php | ||
link-manager.php | ||
link-parse-opml.php | ||
link.php | ||
load-scripts.php | ||
load-styles.php | ||
media-new.php | ||
media-upload.php | ||
media.php | ||
menu-header.php | ||
menu.php | ||
moderation.php | ||
ms-admin.php | ||
ms-delete-site.php | ||
ms-edit.php | ||
ms-options.php | ||
ms-sites.php | ||
ms-themes.php | ||
ms-upgrade-network.php | ||
ms-users.php | ||
my-sites.php | ||
nav-menus.php | ||
network.php | ||
options-discussion.php | ||
options-general.php | ||
options-head.php | ||
options-media.php | ||
options-permalink.php | ||
options-privacy.php | ||
options-reading.php | ||
options-writing.php | ||
options.php | ||
plugin-editor.php | ||
plugin-install.php | ||
plugins.php | ||
post-new.php | ||
post.php | ||
press-this.php | ||
privacy-policy-guide.php | ||
privacy.php | ||
profile.php | ||
revision.php | ||
setup-config.php | ||
site-editor.php | ||
site-health-info.php | ||
site-health.php | ||
term.php | ||
theme-editor.php | ||
theme-install.php | ||
themes.php | ||
tools.php | ||
update-core.php | ||
update.php | ||
upgrade-functions.php | ||
upgrade.php | ||
upload.php | ||
user-edit.php | ||
user-new.php | ||
users.php | ||
widgets-form-blocks.php | ||
widgets-form.php | ||
widgets.php |