Removal of the AccessiblePrivateMethods trait in WooCommerce 10.5

The AccessiblePrivateMethods trait was introduced in WooCommerce 7.0 as a means to use private methods as targets of hooks, clearly signaling that these shouldn’t be used for any other purpose. The trait was in the Internal namespace so not intended for usage outside of WooCommerce core.

In WooCommerce 9.6 we removed all usages of the trait, in favor of the more simple approach of making the hook target methods public and marking them with an @internal annotation.

WooCommerce 10.5 will completely remove the AccessiblePrivateMethods trait. The trait doc block was updated with a “DO NOT USE” notice and a warning about it being removed in WooCommerce 10.5.

How can developers tell if they are affected?

Nobody outside of WooCommerce should be affected since the trait being removed was in the Internal namespace and thus not intended for usage outside of WooCommerce core (also the removal notice was introduced in 9.6). Any extensions using the trait will break in WooCommerce 10.5.

What action do developers need to take if affected?

Extensions (incorrectly) using the trait should copy over the trait code (can be extracted from the PR itself, or from an earlier version of WooCommerce) so that it becomes part of the extension itself. Alternatively (and recommended), they can stop using the trait as we did in WooCommerce core, see this discussion on GitHub.


Leave a Reply

Your email address will not be published. Required fields are marked *