Make WordPress Core

Opened 12 days ago

Last modified 16 hours ago

#59360 assigned defect (bug)

update_network_option() strict checks can cause false negatives

Reported by: mukesh27's profile mukesh27 Owned by: mukesh27's profile mukesh27
Milestone: 6.4 Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords: needs-patch needs-unit-tests
Focuses: performance Cc:


Follow up: #22192

add_network_option( $network_id, $option_name, 1 );
update_network_option( $network_id, $option_name, 1 );

The update should not work, because they are the same. However, the meta cache will have "1" as a string, and then it will strict compare it to 1 as an integer. Thus, an unnecessary update will run.

It is quite common to use integers and booleans directly into these functions. They should be smart enough to recognize that "1" == 1 == true and "0" == 0 == false, and that any numeric string is also equal to a properly cast integer.

The new changes need unit tests.

Ticket from which this was spun: #22189, saving navigation menus is slow.

cc. @flixos90 @spacedmonkey @joemcgill

Change History (1)

This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.

16 hours ago

Note: See TracTickets for help on using tickets.