[wp-trac] [WordPress Trac] #61484: Prime notoptions within `delete_option()`, `delete_network_option()`.

WordPress Trac noreply at wordpress.org
Mon Jun 24 04:45:14 UTC 2024


#61484: Prime notoptions within `delete_option()`, `delete_network_option()`.
--------------------------------+-----------------------------
 Reporter:  peterwilsoncc       |      Owner:  (none)
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:
 Severity:  normal              |   Keywords:
  Focuses:  performance         |
--------------------------------+-----------------------------
 When an option is deleted from the database, it becomes known that the
 option does not exist. However, the `notoptions` cache is not primed to
 include this information.

 The result is that a subsequent call to get the option will query the
 database unnecessarily. Priming the notoptions cache in this instance will
 prevent these queries.

 {{{
 $ wp shell
 wp> update_option( 'delete_option_testing', 'yes' );
 => bool(true)
 wp> get_num_queries();
 => int(42)
 wp> get_option( 'delete_option_testing' );
 => string(3) "yes"
 wp> get_num_queries();
 => int(42)
 wp> delete_option( 'delete_option_testing' );
 => bool(true)
 wp> get_num_queries();
 => int(45)
 wp> get_option( 'delete_option_testing' );
 => bool(false)
 wp> get_num_queries();
 => int(46)
 }}}

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


More information about the wp-trac mailing list