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

WordPress Trac noreply at wordpress.org
Mon Sep 25 16:24:08 UTC 2023


#22192: update_option() strict checks can cause false negatives
-------------------------------------------------+-------------------------
 Reporter:  nacin                                |       Owner:  mukesh27
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  6.4
Component:  Options, Meta APIs                   |     Version:
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch 2nd-opinion dev-feedback   |     Focuses:
  has-unit-tests                                 |  performance
-------------------------------------------------+-------------------------
Changes (by flixos90):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56681" 56681]:
 {{{
 #!CommitTicketReference repository="" revision="56681"
 Options, Meta APIs: Improve logic to avoid unnecessary database writes in
 `update_option()`.

 Prior to this change, a strict comparison between the old and new database
 value could lead to a false negative, since database values are generally
 stored as strings. For example, passing an integer to `update_option()`
 would almost always result in an update given any existing database value
 for that option would be that number cast to a string.

 This changeset adjusts the logic to perform an intentional "loose-y"
 comparison by casting the values to strings. Extensive coverage previously
 added in [56648] provides additional confidence that this does not
 introduce any backward compatibility issues.

 Props mukesh27, costdev, spacedmonkey, joemcgill, flixos90, nacin,
 atimmer, duck_, boonebgorges.
 Fixes #22192.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/22192#comment:49>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list