Asked  7 Months ago    Answers:  5   Viewed   25 times

Say a user clicked a button, which resulted in a jquery ajax request being sent to my server.

The server begins a complicated process in response to the ajax request. Lets say that process takes 5 minutes to finish.

In the meantime the user gets bored and closes his browser window.

Will the script on the server continue its processing until it finishes on its normal time, or will it stop?

Same thing if the user visits a url, e.g example.com/process.php?data=xxx. This starts process.php which begins to process the data, and will take 5 mins to finish processing.

Will this processing always continue on, or if the user closes the browser, will it stop?

(I'm asking because I'm concerned about the process being left half finished and resulting in corrupt data).

 Answers

61

PHP won't notice that the browser closed the connection unless it tries to output something (e.g. echo). If it fails to output something, the script will be terminated unless ignore_user_abort is On.

So the script will terminate only if the following conditions are met:

  • the script attempts to output something (because the script won't notice that the user aborted the connection until then)
  • AND php's ignore_user_abort setting is off (if the setting is off, php will terminate the script if fails to output something)

You can avoid the script from terminating by enabling ignore_user_abort.

You can use connection_aborted() at anytime to check is the browser aborted the request.

A script can terminate unexpectedly for other reasons (e.g. max execution time, exception, etc); so you should make use of transactions, so that half-finished changes are canceled if the script terminates abnormally.

Wednesday, March 31, 2021
 
Isky
answered 7 Months ago
86

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Wednesday, March 31, 2021
 
ojrac
answered 7 Months ago
99

Have you installed PHP? - If so do the following:

  1. Start off by trying a simple script - call it say info.php:

  2. Ensure (assuming Apache) that you have it the web server configured - see http://php.net/manual/en/install.php

If all this works then there is a problem with the script.

Friday, May 28, 2021
 
Juicy
answered 5 Months ago
79

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
 
Nate
answered 5 Months ago
22

Based on your clarifying comments, it appears your browser is accessing a previous version of your app server.

I have run into this problem myself when using the PyCharm IDE. On Windows, the way to shut down these old versions of the server is to press either Ctrl+Alt+Delete or Ctrl+Shift+Esc (Windows 10) to view your list of running processes. Then scroll down until you see processes named Python and shut them all down.

Wednesday, August 4, 2021
 
Philip Weiser
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :