[wp-trac] [WordPress Trac] #59360: update_network_option() strict checks can cause false negatives

WordPress Trac noreply at wordpress.org
Fri Sep 15 07:47:03 UTC 2023


#59360: update_network_option() strict checks can cause false negatives
--------------------------------+------------------------------------------
 Reporter:  mukesh27            |      Owner:  mukesh27
     Type:  defect (bug)        |     Status:  assigned
 Priority:  normal              |  Milestone:  6.4
Component:  Options, Meta APIs  |    Version:
 Severity:  normal              |   Keywords:  needs-patch needs-unit-tests
  Focuses:  performance         |
--------------------------------+------------------------------------------
 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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59360>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list