[wp-trac] [WordPress Trac] #54677: Default widgets with alternative option name causing unnecessary database queries

WordPress Trac noreply at wordpress.org
Wed Jul 6 00:53:14 UTC 2022


#54677: Default widgets with alternative option name causing unnecessary database
queries
-------------------------------------------------+-------------------------
 Reporter:  Chouby                               |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  6.1
Component:  Widgets                              |     Version:  5.8
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing has-unit-    |     Focuses:
  tests                                          |  performance
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 In the [https://github.com/WordPress/wordpress-develop/pull/2951 linked
 pull request]:

 * no change to `WP_Widget::save_settings()` it always uses
 `$this->option_name`.
 * `WP_Widget::get_settings()` uses `$this->option_name` if it it exists
 * `WP_Widget::get_settings()` falls back `$this->alt_option_name` if it it
 exists
 * `WP_Widget::get_settings()` initializes `$this->option_name` if neither
 exist
 * `WP_Widget::get_settings()` migrates `$this->alt_option_name` to
 `$this->option_name` only the alt option is set
 * If both options exist then no changes are made to the database -- doing
 so would create extra db queries if the alt option was not set.

 Testing notes:

 * no options creates `options_name`
 * alt option exists and is migrated to `option_name`
 * new option exists does not create `alt_option_name`
 * if both options exist then both remain in the database

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


More information about the wp-trac mailing list