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?

  • 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, 2013 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 Jan 15, 2013 at 15:38
  • Its not server load issue because server is mine Jan 15, 2013 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, 2013 at 16:05
  • Yeah, i am asking how to do it in question. I know problem as i described in title. Jan 15, 2013 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
  • I can make php executing unlimited but just curious on how i can split work for future development Jan 16, 2013 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, 2013 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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