[wp-trac] [WordPress Trac] #28701: Deleted option is not deleted if value was ever null

WordPress Trac noreply at wordpress.org
Tue Jul 1 04:15:05 UTC 2014


#28701: Deleted option is not deleted if value was ever null
--------------------------------+-----------------------------
 Reporter:  rmccue              |      Owner:
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:  2.2
 Severity:  normal              |   Keywords:
  Focuses:                      |
--------------------------------+-----------------------------
 If an autoloaded option ever contains `null`, it will cease to be
 autoloaded after this. It will then be stored in the individual option
 cache (`wp_cache_get('optname', 'options')`), rather than the autoloaded
 options. The autoloaded option cache will then contain `optname` with the
 value `null` (and `isset(null) === false`).

 Typically, this would be fine, but `delete_option` checks the database
 autoload value directly. It then only attempts to delete this from the
 autoload options cache (which again fails because of an isset check).

 After deleting, the value is still stored in the object cache (!!!),
 causing it to return a value despite not existing in the database.

 As far as I can tell, this has existed since r4855 (WP 2.2).

 ----

 To reproduce (requires external object cache to be enabled):
 {{{
 // Add the option with initial value set to null
 add_option( 'testingkey', null );

 // Update to real value
 update_option( 'testingkey', 'realvalue' );

 // Delete the option completely
 delete_option( 'testingkey' );

 // Check the value
 var_dump( get_option( 'testingkey', 'default' ) );
 }}}

 Expected result:
 {{{
 string(7) "default"
 }}}

 Actual result:
 {{{
 string(9) "realvalue"
 }}}

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


More information about the wp-trac mailing list