Ticket #1499 (closed defect (bug): fixed)

Opened 7 years ago

Last modified 5 years ago

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

Reported by: westi Owned by: markjaquith
Priority: normal Milestone:
Component: Optimization Version: 1.5.2
Severity: minor Keywords: bg|has-patch bg|commit
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

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

Change History

westi7 years ago

Patch to functions.php to improve add_option

  • Keywords bg|has-patch bg|2nd-opinion added
  • Milestone set to 1.5.2

comment:3   matt7 years ago

  • Milestone changed from 1.5.2 to 1.6

Looks good. Caching is good :)

Patch for WP 1.6 SVN

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

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

comment:6   ryan6 years ago

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

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

  • Milestone 2.0 deleted

Milestone 2.0 deleted

Note: See TracTickets for help on using tickets.