[wp-trac] [WordPress Trac] #19771: Re-initiate MySQL connections

WordPress Trac wp-trac at lists.automattic.com
Sat Jan 7 17:30:46 UTC 2012


#19771: Re-initiate MySQL connections
--------------------------+-----------------------------
 Reporter:  kieranbarnes  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:  3.3.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Is there any reason why WordPress doesn't re-initiate it's MySQL
 connection before it does a DB query?

 For example, I have some code


 {{{
 $the_query = new WP_Query($args);
 while ( $the_query->have_posts() ) : $the_query->the_post();

 update_post_meta(get_theid(), 'meta_key', 'meta_value'); // this obviously
 works

 // DO SOMETHING THAT TAKES AGES
 // LIKE UPLOAD A VIDEO TO VIMEO, SOMETHING THAT IS LONGER THAN YOUR
 // MYSQL wait_timeout VALUE

 update_post_meta(get_theid(), 'meta_key1', 'meta_value1'); // this fails
 quite silently and quite annoyingly.
 endwhile;
 }}}


 If you do something in a loop that takes longer than your MySQL
 wait_timeout and the WP DB connection is closed by MySQL, it doesn't try
 to to reopen it. The code will fail, or return false.

 I've spent a few days writing a script that uploads videos from a custom
 field over to Vimeo. update_post_meta was failing intermittently. Extra
 debugging with $wpdb->last_error suggests <em>"MySQL server has gone
 away"</em>

 I'm fairly confident update_post_meta / add_post_meta / any other function
 should check if the MySQL connection is open before executing the required
 query.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19771>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list