0

I have built a PHP script for uploading data from Excel (~40KB size) into DB sent via an Ajax request. It will insert 200 events, 500 registrations (Registrations for the events calendar pro plugin), insert around 500 users and pages and create 1000 PDFs.

It will insert/create this one by one (first events, then registrations etc.) and when I upload a smaller batch, the entire script works just fine. I can hereby upload the entire data, just in smaller pieces.

However, when I upload the entire data, it will always stop at the 3rd step (the insert of the users) and it will always do it at around 200 users without returning anything anymore - In the Console - Network Inspector it is still running.

I have increased the PHP settings to very high, but the error still exists:

memory_limit = 8216M
max_execution_time = 3600
max_input_time = 3600
post_max_size = 1028M
upload_max_filesize = 1028M

Can there be any setting either in PHP, Server or Wordpress that can cause this issue? I am just lost now after sitting on this now for a couple of days, if anyone has a hint or idea, thanks a lot in advance.

9
  • Whats your code? Commented Jun 7, 2018 at 14:48
  • I guess you have just bad design. You need to detach upload action from other actions like "It will insert 200 events, 500 registrations". If you have everything together - that is the mess and impossible to debug and monitor. You have this long response not because of file upload, but waiting all those heavy inserts get done. Commented Jun 7, 2018 at 14:50
  • Did you look at your PHP Error log yet to see the error message produced when it stops running? Commented Jun 7, 2018 at 14:51
  • and create 1000 PDFs are you kidding me? :-) Same action? this kind of jobs should be done I would say like a cron job, but not ajax simple request :-) Commented Jun 7, 2018 at 14:53
  • the log says: Premature end of script headers: index.php. Is it really impossible to get it done via ajax ... that would mean I need to re-organize so much :( Commented Jun 7, 2018 at 15:09

1 Answer 1

1

Like all the commentors are stating, the tasks you are trying to complete feel a bit much for an ajax call.

I'm guessing you regularly update the Excel file and need to update it to WP?

Is it ok if I was to return the ajax call after each insert-step and then start a new one.

Sure that's an option, i've build many ajax batch loaders for collecting large data sets and sending mail. This way you also circumvent PHP script timeouts.

Sign up to request clarification or add additional context in comments.

1 Comment

I went for this solution to circumvent PHP script timeouts

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.