Opened 3 years ago

Closed 21 months ago

#15497 closed defect (bug) (fixed)

update_site_option can fail for values that cast to false

Reported by: duck_ Owned by: duck_
Priority: normal Milestone: 3.3
Component: General Version: 3.0
Severity: normal Keywords: 3.3-early westi-likes has-patch commit
Cc:

Description

Passing a value to update_site_option that casts to false (e.g. 0) doesn't work when the site option doesn't already exist because of:

if ( $value && !$wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
    return add_site_option( $option, $value );

update_option has no such restriction (the first part of the conditional).

Found when investigating #15496 as the compression test might call update_site_option('can_compress_scripts', 0);, so in some circumstances the compression test is loaded on every admin screen.

Attachments (1)

15497.diff (729 bytes) - added by duck_ 3 years ago.

Download all attachments as: .zip

Change History (6)

duck_3 years ago

  • Keywords 3.2-early added
  • Milestone changed from Awaiting Review to Future Release
  • Keywords 3.3-early westi-likes commit added; 3.2-early removed
  • Owner set to westi
  • Status changed from new to assigned
  • Owner changed from westi to duck_
  • Milestone changed from Future Release to 3.3
  • Resolution set to fixed
  • Status changed from assigned to closed

In [18589]:

Allow update_site_option to add false-y values. Fixes #15497

Note: See TracTickets for help on using tickets.