Skip to:

Opened 10 years ago

Closed 10 years ago

#5385 closed enhancement (fixed)

Add default options at installation/upgrade to 2.0

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 2.0 Priority: normal
Severity: normal Version:
Component: Core Keywords:


BP loads many options during its bootstrap. Some are done in a single query (bp_core_get_root_options()), while others are checked along the way. Options that exist in the database, and are set to autoload, are fetched by WordPress the first time that wp_load_alloptions() is called; this ensures that future calls to get_option() will hit the cache instead of resulting in another DB query. However, for those options that are *not* found in the database, a separate (and, of course, unsuccessful) DB query is made. (This only happens when not using a persistent cache; otherwise these misses are stored in 'notoptions'.)

For this reason, I suggest that we install all of our default options in the DB at installation. That way, we can avoid all the unnecessary queries for stuff like 'bp-blogs-first-install'. In my tests, this can cut 10-15 queries per pageload off of a fresh installation of BuddyPress. (Keep the "fresh" point in mind. If you have an old development installation, it's likely that most settings are saved in your database.)

We already have a function bp_add_option() that must've been ported from bbPress but is unused. The attached patch updates the list of default options, and fires bp_add_option() at installation/upgrade. Any reasons not to do this?

Attachments (1)

5385.patch (2.7 KB) - added by boonebgorges 10 years ago.

Download all attachments as: .zip

Change History (2)

10 years ago

#1 @boonebgorges
10 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 7904:

Install default options at installation time and at upgrade to 2.0

When BuddyPress is installed, all basic config options should be saved to the
database, even when the setting is empty (0). This ensures that the options
will be pre-fetched by the first call to wp_load_alloptions() and stored in the
non-persistent cache, removing the necessity to make additional failed queries
to the wp_options table.

This changeset also includes logic to add missing default options to existing
default installations when upgrading to 2.0.

Fixes #5385

Note: See TracTickets for help on using tickets.