[Enhancement]: Allow suppression of "Function is_internal_meta_key was called incorrectly" PHP notice #47538
Labels
focus: order
Issues related to orders.
priority: normal
The issue/PR is of normal priority—not many people are affected or there’s a workaround, etc.
team: Proton
type: community contribution
type: enhancement
The issue is a request for an enhancement.
Describe the solution you'd like
The following code will result in a PHP notice of "Notice: Function is_internal_meta_key was called incorrectly. Generic add/update/get meta methods should not be used for internal meta data, including "_billing_email". Use getters and setters."
I understand the recommended method is to use
$order->get_billing_email
for the above, however in some scenarios the use of a generic$order->get_meta
for internal keys is useful, just some examples of this could be that you're building functionality which allows a backend user to:In these scenarios the code will work, and due to the conditions of
$order->get_meta()
it does in fact use the internal meta function https://woocommerce.github.io/code-reference/files/woocommerce-includes-abstracts-abstract-wc-data.html#source-view.348I'd like to see a means of being able to suppress that notice being done by
is_internal_meta_key()
https://woocommerce.github.io/code-reference/files/woocommerce-includes-abstracts-abstract-wc-data.html#source-view.329 for when you have a scenario like the 2 examples above, ideally with a PHP filter hook.Describe alternatives you've considered
I understand there may be a means of checking if the meta being got is an internal Woo order meta key and instead calling the function, but I don't really see the point when it is already doing it via
$order->get_meta
, albeit with the notice, you'll just be duplicating what that is already doing.Additional context
No response
The text was updated successfully, but these errors were encountered: