[wp-trac] [WordPress Trac] #58087: Fix the 'data' dynamic property in WP_Term

WordPress Trac noreply at wordpress.org
Mon Apr 1 16:37:54 UTC 2024


#58087: Fix the 'data' dynamic property in WP_Term
-------------------------------------+-------------------------------------
 Reporter:  antonvlasenko            |       Owner:  hellofromTonya
     Type:  defect (bug)             |      Status:  accepted
 Priority:  normal                   |   Milestone:  6.6
Component:  Taxonomy                 |     Version:  6.3
 Severity:  minor                    |  Resolution:
 Keywords:  php82 needs-testing      |     Focuses:  coding-standards, php-
  has-patch has-unit-tests changes-  |  compatibility
  requested early                    |
-------------------------------------+-------------------------------------

Comment (by hellofromTonya):

 `WP_Term`'s `data` property's design is on purpose. By design, it's value
 is initially initialized / set each time when getting the `data` property.

 This design for late / lazily init / set of known, named dynamic
 properties exist elsewhere in Core, such as in `WP_Block::attributes`.

 As it's by design, a new strategy is needed. It can't be initialized in
 the constructor. While adding a new getter method could work too, a more
 generic approach is needed to ensure the code continues to work as it has
 while also fixing the `isset()` and getting rid of the dynamic property
 deprecation (and later fatals).

 I opened #60875 to lay out an architectural strategy for all instances of
 this type of named known late init dynamic property (long name right lol).

 @antonvlasenko and I have discussed this design and impacts. He's planning
 to adjust his PR to the new strategy. I'd suggest this new approach to be
 committed `early` in 6.6 to give a long soak time for any unknowns for
 further adjustments (to the strategy) if needed.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58087#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list