Make WordPress Core

Changes between Initial Version and Version 23 of Ticket #61890


Ignore:
Timestamp:
08/27/2024 03:00:13 PM (7 months ago)
Author:
hellofromTonya
Comment:

Updated the summary and description to match the 2 approaches proposed in this ticket to mitigate the issue.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #61890

    • Property Keywords has-patch has-unit-tests needs-testing needs-dev-note has-testing-info added
    • Property Version changed from to 4.4
    • Property Summary changed from Handle WP_Term known, named dynamic properties for PHP 8.2 to Handle WP_Term dynamic properties for PHP 8.2
  • Ticket #61890 – Description

    initial v23  
    66>RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
    77
    8 == Tasks
     8The epic ticket provides recommendations for how to handle dynamic properties:
    99
    10 === Identify all of the known, named dynamic properties Core adds and uses
     10
     11== Mitigation Approaches
     12
     13This ticket offers 2 different approaches. It uses the epic ticket #56034 as the guide for mitigation.
     14
     15=== **Approach 1: Declare Core's known, named and deprecate dynamic properties.**
     16
     17Per #56034:
     18>Situation: Known, named, dynamic property
     19>Resolution: Declare the property on the (parent) class
     20
     21This approach proposes to:
     22* Soft remove support of dynamic properties by deprecating getting dynamic properties.
     23* Identify and declare all of Core's known, named dynamic properties on the `WP_Term` class.
     24
     25Goals:
     26* Remove Core's dynamic properties.
     27* Alert extenders via deprecation notice and dev note.
     28* Extenders to remove their `WP_Term` dynamic properties and replace with a different custom handling approach. (Note: need to figure out what to recommend to extenders for this migration process.)
     29
     30Tasks:
     31
     321. Identify all of the known, named dynamic properties Core adds and uses.
    1133
    1234Beyond the `'data'` dynamic property (previously discussed in #58087), Core adds and uses a lot of other known, named dynamic properties. For example:
     
    1739A first step is to identify all of the dynamic properties that Core adds and uses.
    1840
    19 === Determine affects / impacts of the preferred solution
     412. Determine affects / impacts of the preferred solution
    2042
    2143#56034 provides guidance for known, named dynamic properties:
     
    2648If found to have an unwanted affect, the compatible fields approach (e.g. `WP_User_Query`) can be explored (see #58897).
    2749
     50=== **Approach 2: Add full support for dynamic properties on `WP_Term`**.
     51
     52Per #56034:
     53>Situation: Known use of unknown dynamic properties
     54>Solution: Declare the full set of magic methods on a class
     55>...
     56>If the class really ''**should**'' support dynamic properties, the magic methods should be implemented on the class itself (or its parent).
     57
     58This approach proposes to:
     59* Fully support dynamic properties on `WP_Term`.
     60* Add a full set of magic methods on the `WP_Term` class.
     61
     62What if extenders are also adding and using dynamic properties?
     63It's been possible since WP_Term was introduced in 2015 in WP 4.4.0 via [34997].
     64
     65Has it been supported since introduction?
     66Yes, as Core itself needed it supported.
     67
     68Since its introduction, this class has supported and actively added / used dynamic properties. Core itself active uses and adds dynamic properties to `WP_Term` objects. Following its example, extenders also add dynamic properties.
     69
     70With `WP_Term` being marked as `final`, there's not a way for extenders to declare their dynamic property needs on a custom child class.
     71
     72It's reasonable to determine that `WP_Term` should fully support dynamic properties. Doing so maintains backward compatibility (BC) with the (hopefully) the lowest risks of breaking things for users.
     73
    2874**References**:
    2975* The changes are part of #56034, which is the larger Dynamic Properties proposal and initiative.