Opened 5 weeks ago
Closed 4 weeks ago
#64085 closed defect (bug) (worksforme)
Missing parentheses in condition in delete_metadata()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 6.8.3 |
| Component: | Options, Meta APIs | Keywords: | |
| Focuses: | Cc: |
Description
In wp-includes/meta.php inside the function delete_metadata() if the following if-condition:
if ( ! $meta_type || ! $meta_key || ! is_numeric( $object_id ) && ! $delete_all ) {
return false;
}
There is a missing parentheses around the last two conditions on this line. As a result, the condition will not be true in the cases where it should be.
A correction would look like this:
if ( ! $meta_type || ! $meta_key || ( ! is_numeric( $object_id ) && ! $delete_all ) ) {
return false;
}
Source: https://github.com/WordPress/WordPress/blob/master/wp-includes/meta.php#L402
Change History (5)
#2
follow-up:
↓ 4
@
5 weeks ago
I actually think that the && is evaluated before the || even without parentheses.
#4
in reply to:
↑ 2
@
5 weeks ago
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
Replying to TobiasBg:
I actually think that the
&&is evaluated before the||even without parentheses.
Yes, see PHP: Operator Precedence. The condition is correct as is, and the additional parentheses would be redundant here.
Introduced in [29421].
Can you write some unit tests that demonstrate this being an issue? With it being 11 years that this behavior has been a part of core, I think it's important to understand exactly what the change would mean.