New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test if set_time_limit exists #5675
Conversation
app/Controllers/entryController.php
Outdated
@@ -169,7 +169,9 @@ public function optimizeAction(): void { | |||
Minz_Request::forward($url_redirect, true); | |||
} | |||
|
|||
@set_time_limit(300); | |||
if (function_exists('set_time_limit')) { | |||
@set_time_limit(300); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@set_time_limit(300); | |
$isTimeLimited = set_time_limit(300); | |
if ($isTimeLimited === false) { | |
continue; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add the logic in function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ColonelMoutarde After PHP8, with function set_time_limit disabled, set_time_limit (or even decorated with @) will cause fatal termination of script.
Prior to PHP 8.0.0, it was possible for the @ operator to disable critical errors that will terminate script execution. For example, prepending @ to a call of a function which did not exist, by being unavailable or mistyped, would cause the script to terminate with no indication as to why.
from https://www.php.net/manual/en/language.operators.errorcontrol.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, https://www.php.net/manual/en/function.set-time-limit.php set_time_limit is available for all php versions from 4 to 8.
The @ is not necessary, especially as you're checking that the function is present just beforehand. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_time_limit is available for all php versions from 4 to 8.
Partially wrong: any function can be disabled, and we have several examples of providers doing so for that specific function
The @ is not necessary
Wrong: there might be a warning with PHP < 8 (the function would exist, but would be disabled). See https://php.watch/versions/8.0/disable_functions-redeclare
…abled functions
Closes #4982
Changes proposed in this pull request:
-@set_time_limit to function_exists then set_time_limit
How to test the feature manually:
1.purge and optimize db
2.refresh and actualize feeds
Pull request checklist:
Additional information can be found in the documentation.