ID: 45264 User updated by: jdm at visi dot com Reported By: jdm at visi dot com Status: Bogus Bug Type: Unknown/Other Function Operating System: Windows PHP Version: 5.2.6 New Comment:
If that is indeed the case, there is a bug in the documentation that needs to be addressed. Please see my quote of the manual page for set_time_limit: "When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out." As you can see from my example code, that is not what is happening. Obviously in my environment where I've got a max_execution_time of 300, calling set_time_limit is changing the maximum execution time to 30, rather than extending it as the documentation states. This is not a bogus bug. Either the documentation is incorrect or the implementation underlying the function is incorrect. If calling set_time_limit(30) after the script has run for 30 seconds affects max_execution_time to the point where the script ends up terminating, then set_time_limit is not extending the time as it is documented to do. Evidently there are a lot of developers who have come to rely on the functionality of set_time_limit() as it is documented, as the gallery code, from which I discovered this defect is commented as though it expects set_time_limit() to extend the time limit rather than set it to the value specified in the parameter of the function call. Previous Comments: ------------------------------------------------------------------------ [2008-06-15 11:46:49] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is correct, if you change it to something else, it should do that. The reason for this is that for some installations the default is unlimited, and you might want to protect parts of your app for running over time. ------------------------------------------------------------------------ [2008-06-13 16:44:51] jdm at visi dot com Description: ------------ Calling set_time_limit appears to not function as it is documented. Per the documentation: When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out. According to my test code, it is actually affecting the ini value of max_execution_time. As a result if the time limit is a smaller value, max_execution_time is altered to a smaller value, and script execution time can be cut short. I tracked this result down through drupal with the gallery2 integration module included where it makes calls to set_time_limit(30), which causes the module administration page to be cut short, even though my max_execution_time is defined to be 300 seconds. In my environment, the included code produces the following output: 300 30 Reproduce code: --------------- print '<p>'.ini_get('max_execution_time').'</p>'; set_time_limit(30); print '<p>'.ini_get('max_execution_time').'</p>'; Expected result: ---------------- I would expect the max_execution_time to either not change or be extended by the amount set in set_time_limit, according to the documented operation of it. i.e., the resulting code should produce either: 300 300 or: 300 330 Actual result: -------------- The resulting code produces this output: 300 30 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45264&edit=1
