[wp-trac] Re: [WordPress Trac] #8949: WP creates duplicate options

WordPress Trac wp-trac at lists.automattic.com
Mon May 25 13:36:56 GMT 2009


#8949: WP creates duplicate options
-------------------------------+--------------------------------------------
 Reporter:  Denis-de-Bernardy  |       Owner:  anonymous  
     Type:  defect (bug)       |      Status:  new        
 Priority:  low                |   Milestone:  2.9        
Component:  Optimization       |     Version:  2.7        
 Severity:  minor              |    Keywords:  needs-patch
-------------------------------+--------------------------------------------
Changes (by vladimir_kolesnikov):

 * cc: vladimir@… (added)


Comment:

 Re: race conditions:

 why not use a statement like this:

 {{{
 INSERT INTO `wp_options` (`blog_id`, `option_name`, `option_value`,
 `autoload`) VALUES
 ('blog_id', 'key', 'value', 'autoload'),
 ON DUPLICATE KEY UPDATE `option_value`=VALUES(`option_value`);
 }}}

 (see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html)

 Thus, if two scripts are trying to insert the same option into the table,
 the first one will insert it, the second one will update it.

 Thoughts?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/8949#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list