Ticket #1499 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

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

Reported by: westi Assigned to: 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 (0.7 kB) - added by westi on 07/08/05 21:53:07.
Patch to functions.php to improve add_option
functions.php.2.diff (0.6 kB) - added by markjaquith on 09/05/05 22:37:18.
Patch for WP 1.6 SVN

Change History

07/08/05 21:53:07 changed by westi

  • attachment functions.php.diff added.

Patch to functions.php to improve add_option

08/11/05 08:45:37 changed by westi

  • keywords set to bg|has-patch bg|2nd-opinion.

08/11/05 10:07:19 changed by westi

  • milestone set to 1.5.2.

08/14/05 17:46:43 changed by matt

  • milestone changed from 1.5.2 to 1.6.

08/23/05 15:13:34 changed by davidhouse

Looks good. Caching is good :)

09/05/05 22:37:18 changed by markjaquith

  • attachment functions.php.2.diff added.

Patch for WP 1.6 SVN

09/05/05 22:38:35 changed by markjaquith

  • keywords changed from bg|has-patch bg|2nd-opinion to bg|has-patch bg|commit.
  • 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!

09/08/05 21:08:48 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

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

11/30/06 19:41:47 changed by

  • milestone deleted.

Milestone 2.0 deleted