admin管理员组文章数量:1332388
I have a custom plugin that inserts multiple rows into a custom table in the wordpress database. After about 50 seconds I get a 504 Gateway Time-out
error. The 50 seconds is around about the time it takes to insert ~400 rows. Anything less, and the script completes just fine.
I've added the usual things to wp-config.php
and .htaccess
wp-config.php
ini_set('max_execution_time', 1000);
ini_set('max_input_time', 1000);
set_time_limit(1000);
.htaccess
php_value memory_limit 256M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 1000
php_value max_input_time 1000
...but none of these seem to make any difference. The script always timeout after about 50 seconds and I get 504 Gateway Time-out The server didn't respond in time
error screen.
My code:
global $wpdb;
$table = 'wp_motorjobs_jobs';
$insert_data = array();
Then I do a foreach
loop where I prepare my data based on some other conditions. I end up with this array structure towards the end of the loop:
$job_data = array(
'title' => $job_title,
'company' => $job_company,
'location' => $job_location,
'type' => $job_type,
'details' => $job_details,
'query' => $search_query,
'site' => $job_site,
'url' => $url,
'date' => $job_date
);
array_push($insert_data, $job_data);
Then I end my loop. This loop could have added hundreds of arrays to $insert_data
. All the data are strings.
Then I prepare my sql query:
$query = "INSERT INTO $table ( title, company, location, type, details, query, site, url, date ) VALUES ";
foreach ( $insert_data as $row ) {
$query .= $wpdb->prepare( "(%s, %s, %s, %s, %s, %s, %s, %s, %s),", $row['title'], $row['company'], $row['location'], $row['type'], $row['details'], $row['query'], $row['site'], $row['url'], $row['date'] );
}
$query = rtrim( $query, ',' ) . ';';
$wpdb->query($query);
After this script runs for about 50 seconds I get the 504 Gateway Time-out
Anyone? Cheers.
本文标签: 504 Gateway Timeout after custom plugin inserts data into mysql database
版权声明:本文标题:504 Gateway Time-out after custom plugin inserts data into mysql database 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742289884a2447595.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论