2

Does someone face such problem?

set_time_limit() function changes the 'max_execution_time' value, but returns false

php -r 'var_dump(ini_get("max_execution_time"), set_time_limit(5), ini_get("max_execution_time"));'

Command line code:1:
string(1) "0"
Command line code:1:
bool(false)
Command line code:1:
string(1) "5"
Kiwi
  • 61
  • 4
  • https://stackoverflow.com/questions/8914257/difference-between-set-time-limit-and-ini-setmax-execution-time – oLDo Jul 26 '22 at 07:31
  • @oLDo I saw that, but still - why does that happening? Cuz, for example, Yii2 has such code in the vendor's Response class: if (!function_exists('set_time_limit') || !@set_time_limit(0)) { Yii::warning('set_time_limit() is not available', __METHOD__); } It triggers a warning when set_time_limit return false – Kiwi Jul 26 '22 at 07:41

1 Answers1

4

Found a solution: If you have enabled xdebug mod in your php.ini - set_time_limit() function will always return false

Kiwi
  • 61
  • 4
  • Can confirm that with PHP 8.1. Removing the modul solves the problem. Does anybody know why xdebug has a problem with this function? – robsch Feb 14 '23 at 09:20
  • Found [this](https://bugs.xdebug.org/view.php?id=2034) which links to [PR](https://github.com/xdebug/xdebug/commit/8802b544ae925fc4124280b8947e0a6a9bea9d34#diff-e58f2b6319d458c0050a72726720d3e2eda9fb5685e6f1d947788e8dd16cc1c4R935). There you can read: _Override set_time_limit with our own function to prevent timing out while debugging_. That would make sense. A time-out during debugging is not helpful. However, I'm wondering why this is also active when one does not debug... – robsch Feb 14 '23 at 09:48