|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests |
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Description: ------------ At PHP 7.0.33-1 + 0 ~ 20181208203126.8 + stretch ~ 1.gbp2ff763 and PHP 7.3.1-1 + 0 ~ 20190113101756.25 + stretch ~ 1.gbp15aaa9, if max_execution_time = 0 and max_input_time > 0, then at the start of any cycle, the max_input_time limit starts to be spent, that is, in fact, max_execution_time becomes equal to max_input_time. For example, a loop: while (true) {}. In the documentation about this nothing is said. As a result, when the max_input_time limit expires, a fatal error occurs: Fatal error: Maximum execution time of 0 seconds exceeded in /var/www/html/....php on line ... The content of message is incorrect, since 0 seconds is the removal of any restriction and cannot expire and the expiration should be max_input_time, not the "execution time". My solution to the problem is: This problem disappears if max_input_time = 0, but disabling the max_input_time limit will critically violate the security of the server, as it will allow multi big long upload attacks. Therefore, in the config and in general, you should leave the standard max_input_time = 60. If the cycle, whatever it was and whatever it was in, may take more than a certain time in max_input_time, then to solve the problem: before the loop, add: $max_execution_time = ini_get('max_execution_time'); //fix php bug - Fatal error in loop - part 1/3 Add to the end of the loop: set_time_limit(ini_get('max_input_time')); //fix php bug - Fatal error in loop - part 2/3 after the cycle add: set_time_limit($max_execution_time); //fix php bug - Fatal error in loop - part 3/3 These actions need to be performed only for long cycles exceeding the standard minute, for the remaining cycles nothing needs to be done. Same old issues: https://bugs.php.net/bug.php?id=37306 https://bugs.php.net/bug.php?id=42706 https://bugs.php.net/bug.php?id=49868 Please, or fix bug, or add information in documentation. Test script: --------------- in php.ini: max_execution_time = 0 max_input_time = 60 script: while (true) {} Expected result: ---------------- infinity loop Actual result: -------------- After 60 second: "Maximum execution time of 0 seconds exceeded in /var/www/html/....php on line ..."