WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#1499 closed defect (bug) (fixed)

add_option shouldn't always check db for pre-existing option

Reported by: westi Owned by: markjaquith
Milestone: Priority: normal
Severity: minor Version: 1.5.2
Component: Optimization Keywords: bg|has-patch bg|commit
Focuses: Cc:

Description

Currently some plugins do the following everytime they are run:

add_option('my_opt',...);
get_option('my_opt',...);

When these options are defined with autoload as yes wordpress automatically loads them at startup - the add_option code should check the cache to see if the option already exists before checking the db to save on queries.

Patch attached to do this cache checking.

Attachments (2)

functions.php.diff (674 bytes) - added by westi 12 years ago.
Patch to functions.php to improve add_option
functions.php.2.diff (564 bytes) - added by markjaquith 12 years ago.
Patch for WP 1.6 SVN

Download all attachments as: .zip

Change History (9)

@westi
12 years ago

Patch to functions.php to improve add_option

#1 @westi
12 years ago

  • Keywords bg|has-patch bg|2nd-opinion added

#2 @westi
12 years ago

  • Milestone set to 1.5.2

#3 @matt
12 years ago

  • Milestone changed from 1.5.2 to 1.6

#4 @davidhouse
12 years ago

Looks good. Caching is good :)

@markjaquith
12 years ago

Patch for WP 1.6 SVN

#5 @markjaquith
12 years ago

  • Keywords bg|commit added; bg|2nd-opinion removed
  • Owner changed from anonymous to markjaquith
  • Severity changed from trivial to minor
  • Status changed from new to assigned
  • Version changed from 1.5.1.2 to 1.5.2

Old patch wasn't working. Recreated it. Let's get this in the core already! It creates a lot of extra queries!

#6 @ryan
12 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [2856]) Check the option cache before querying. Props westi. fixes #1499

#7 @anonymous
11 years ago

  • Milestone 2.0 deleted

Milestone 2.0 deleted

Note: See TracTickets for help on using tickets.