WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#6830 closed enhancement (wontfix)

Eliminate all non-existent options in core and bundled themes/plugins

Reported by: markjaquith Owned by:
Milestone: Priority: high
Severity: normal Version: 2.5
Component: Optimization Keywords: has-patch tested
Focuses: Cc:

Description

Calling get_option() on non-existent options (without an object cache enabled) results in needless SQL queries.

Current ones in 2.5 with the Default theme:

array(3) {
  [0]=>
  string(82) "SELECT option_value FROM wptrunk_options WHERE option_name = 'widget_text' LIMIT 1"
  [1]=>
  float(0.000216960906982)
  [2]=>
  string(10) "get_option"
}
array(3) {
  [0]=>
  string(81) "SELECT option_value FROM wptrunk_options WHERE option_name = 'widget_rss' LIMIT 1"
  [1]=>
  float(0.000195980072021)
  [2]=>
  string(10) "get_option"
}
array(3) {
  [0]=>
  string(91) "SELECT option_value FROM wptrunk_options WHERE option_name = 'kubrick_header_image' LIMIT 1"
  [1]=>
  float(0.000408887863159)
  [2]=>
  string(10) "get_option"
}
array(3) {
  [0]=>
  string(91) "SELECT option_value FROM wptrunk_options WHERE option_name = 'kubrick_header_color' LIMIT 1"
  [1]=>
  float(0.000301837921143)
  [2]=>
  string(10) "get_option"
}
array(3) {
  [0]=>
  string(93) "SELECT option_value FROM wptrunk_options WHERE option_name = 'kubrick_header_display' LIMIT 1"
  [1]=>
  float(0.000277996063232)
  [2]=>
  string(10) "get_option"
}

They're quick, but it's sloppy that they're there at all. All of our options should be initialized with add_option().

Attachments (3)

6830.001.diff (5.9 KB) - added by markjaquith 7 years ago.
6830.002.diff (4.7 KB) - added by cnorris23 5 years ago.
6830.003.diff (7.1 KB) - added by cnorris23 5 years ago.

Download all attachments as: .zip

Change History (16)

@markjaquith7 years ago

comment:1 @markjaquith7 years ago

  • Keywords has-patch needs-testing added

Patch initializes those options, as well as fixes some kubrick_header_color funkiness where it'd go blank and show grey text in the backend.

comment:2 @jacobsantos7 years ago

  • Keywords needs-patch added; has-patch needs-testing removed
  • Type changed from defect to enhancement

kubrick options should be setup using the themes functions.php. Themes should also have uninstall in order to remove options created. Widget code is good.

comment:3 @Denis-de-Bernardy6 years ago

no traction?

comment:4 @Denis-de-Bernardy6 years ago

  • Milestone changed from 2.9 to Future Release

comment:5 @cnorris235 years ago

  • Keywords close added; needs-patch removed

I vote we close this since we're getting a new default theme, 2010.

comment:6 follow-up: @Denis-de-Bernardy5 years ago

  • Keywords close removed

nope, we should fix this, because the option clutter will remain even with a new theme.

comment:7 in reply to: ↑ 6 @cnorris235 years ago

Good call. I was forgetting the fact that kubrick isn't just going to disappear because we're getting a default theme.

i've updated the patch for 3.0, unless we can pretend it's a security patch and get it into 2.9.2.

@cnorris235 years ago

comment:8 @cnorris235 years ago

  • Milestone changed from Future Release to 3.0

comment:9 @cnorris235 years ago

  • Keywords has-patch added

comment:10 @Denis-de-Bernardy5 years ago

widget_text and widget_rss are still used, aren't they? they're for the text and rss widgets.

comment:11 @cnorris235 years ago

Yeah, they're both still used. When I actually got into Mark's patch, nothing was actually being eliminated, so unless I'm misinterpreting populate_options() in wp-admin/includes/schema.php, the widget_rss and widget_text options are added and set as blank as long as they do not already exist.

To be honest, I'm not entirely sure why they were added at that time, as they were not being called by the default theme. I just took Mark's word for it. On top of that, they are already added a few lines up (schema.php) for 2.7, and I missed them. I've updated the patch.

@cnorris235 years ago

comment:12 @Denis-de-Bernardy5 years ago

  • Keywords tested added

works fine. gets my vote.

one note: the $_REQUEST[defaults] part doesn't seem to be used at all. or maybe it's for a non-js version.

comment:13 @nacin5 years ago

  • Milestone 3.0 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Kubrick is officially out of core.

Note: See TracTickets for help on using tickets.