[wp-trac] [WordPress Trac] #61890: Handle WP_Term known, named dynamic properties for PHP 8.2
WordPress Trac
noreply at wordpress.org
Tue Aug 27 08:49:33 UTC 2024
#61890: Handle WP_Term known, named dynamic properties for PHP 8.2
-------------------------------------+-------------------------------------
Reporter: hellofromTonya | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.7
Component: Taxonomy | Version: 4.4
Severity: minor | Resolution:
Keywords: php82 has-patch has- | Focuses: coding-standards, php-
unit-tests needs-testing needs- | compatibility
dev-note has-testing-info |
-------------------------------------+-------------------------------------
Comment (by adrianduffell):
Thanks for working on this and reaching out to us WooCommerce!
It looks like a tricky job for WooCommerce to fully audit potential
issues. If I understand correctly, we would need to:
* A) identify dynamic properties added to a WP_Term object, in combination
with
* B) that object being cast to an array
That said, dynamic properties have been a source of clashes within our
ecosystem. I would prefer to see their usage removed / discouraged.
Generally, we have seen issues in the wild where two different WooCommerce
extensions independently add the same named dynamic property to an object
but expect different types - e.g. one may expect a string and the other a
boolean. Clashes ensue when the object is passed between functions.
Overall we have decided to swim in the direction PHP is taking and
discourage their use (see issue
https://github.com/woocommerce/woocommerce/issues/45286).
> How can extenders declare their dynamic property on the class? They
can't.
I could see this being an opportune time to deprecate such use in WP_Term
and encourage safer coding patterns. As WordPress doesn’t seem to have
been actively encouraging extenders to add dynamic properties to the
class, I think it would be reasonable to drop support for it in-line with
PHP’s motives.
What are your thoughts on adding the full set of magic methods to WP_Term
as a temporary workaround but including a _doing_it_wrong notice when a
dynamic property is used? For WooCommerce at least, this would help us
identify any usage in the ecosystem and promote safer patterns being used.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61890#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list