Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In one of my plugins, I need to insert about 1000 terms into a custom taxonomy while installing a plugin. I see it's sometimes causing 500 internal server error. How can I split that work or prevent it from giving an error?

share|improve this question
3  
Can you turn on error reporting/logging and let us know what the error is? A 500 message simply indicates an error occurred, it isn't an error in of itself –  Tom J Nowell Jan 15 '13 at 14:55
    
mod_fcgid: read data timeout in 31 seconds, referer: /wp-admin/network/plugins.php Premature end of script headers: plugins.php, referer: /wp-admin/network/plugins.php –  Ünsal Korkmaz Jan 15 '13 at 15:38
    
Its not server load issue because server is mine –  Ünsal Korkmaz Jan 15 '13 at 15:49
    
Nobody suggested it was, you simply ran out of time executing the PHP script. The obvious answer being to separate the 1000 term list into batches to be executed sequentially in separate page requests –  Tom J Nowell Jan 15 '13 at 16:05
    
Yeah, i am asking how to do it in question. I know problem as i described in title. –  Ünsal Korkmaz Jan 15 '13 at 16:06

1 Answer 1

Are your database tables using the InnoDB engine? If so, and the plugin is just for your website, start a transaction, run the inserts, commit the transaction (or rollback on error).

global $wpdb;
$wpdb->query('start transaction');
// do the inserts
$wpdb->query('commit');
share|improve this answer
    
I can make php executing unlimited but just curious on how i can split work for future development –  Ünsal Korkmaz Jan 16 '13 at 15:21
    
OK, so you're not asking for a solution, you want a strategy. There are many, some posted in this stack. Have you tried searching? –  webaware Jan 16 '13 at 23:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.