Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#19771 closed defect (bug) (duplicate)

Re-initiate MySQL connections

Reported by: kieranbarnes's profile kieranbarnes Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: Database Keywords:
Focuses: Cc:

Description

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.

Change History (2)

#2 @ryan
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.