Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #58896


Ignore:
Timestamp:
07/24/2023 09:53:48 PM (17 months ago)
Author:
hellofromTonya
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #58896

    • Property Version changed from to 4.0
  • Ticket #58896 – Description

    initial v2  
    1 Changes requested are:
    2 
    3 1. Change 1: Add a notice to each of the `WP_List_Table` magic methods to alert and inform developers when attempting to get/set/isset/unset a dynamic property.
    4 
    51`WP_List_Table` has a list of compatible fields (`compat_fields`), which was introduced at the same time as the magic methods. The fields in `compat_fields` list are then not dynamic properties, as the magic methods properly handle each. But fields not in that list are dynamic properties.
    62
     
    1511When a dynamic property is called on this class, there's no information given to the developer. The notice of `_doing_it_wrong()` will provide the alert to developers to modify their code.
    1612
    17 2. Change 2: Add `return null` in `__get()` when attempting to get a dynamic property that is not in the `compat_fields`.
     13Also notice: the `compat_fields` are essentially public properties through the magic methods.
     14
     15Thus, there are 2 ways to fix this class to be compatible with PHP 8.2's dynamic properties:
     16
     171. **Option 1**: Fix the magic methods:
     18
     19* Change 1: Add a notice or `_doing_it_wrong()` to each magic method, i.e. to alert and inform developers when attempting to get/set/isset/unset a dynamic property.
     20
     21* Change 2: Add `return null` in `__get()` when attempting to get a dynamic property that is not in the `compat_fields`.
     22
     232. **Option 2**: Add each `compat_fields` as a `public` property and remove the magic methods.
    1824
    1925Props to @jrf for identifying the issue.