0

I have a PHP script without any "set_time_limit()" defined. The PHP.ini max_execution_time = 30 The script opens a mysql connection and performs a variable loop of queries on the same connection, then it closes after processing. The loop is variable, and the script could run anywhere from 1 sec to 1000 sec. I would expect the script to abort at the default 30 second limit, but that doesn't happen.

I suspect the mysql connection is superseding the PHP timeout default and preventing the script from aborting. Does anybody know if this could be possible?

The script is very complex and doesn't make sense to put it here. But it surely has no time limits.

Note: I am not trying to impose a time limit and this behavior is actually good for my script. I just want to know more about this behavior.

noderman
  • 1,934
  • 1
  • 20
  • 36

1 Answers1

0

Thanks to Jono20201.

So this question explains it:

PHP max_execution_time not timing out

Summarizing: the time spent outside the script is not accounted for (MySQL running the queries, for example), so there is nothing that set_time_limit and max_execution_time can do.

EXCEPT on Windows. According to PHP documentation:

set_time_limit

The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

Community
  • 1
  • 1
noderman
  • 1,934
  • 1
  • 20
  • 36