Skip to content

Commit

Permalink
Include set_time_limit in a try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviocopes committed Nov 26, 2015
1 parent 6389066 commit ae39aab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions system/src/Grav/Common/GPM/Response.php
Expand Up @@ -78,10 +78,9 @@ public static function get($uri = '', $options = [], $callback = null)
throw new \RuntimeException('Could not start an HTTP request. `allow_url_open` is disabled and `cURL` is not available');
}

// disable time limit if possible to help with slow downloads
if (!Utils::isFunctionDisabled('set_time_limit') && !ini_get('safe_mode')) {
try {
set_time_limit(0);
}
} catch (\Exception $e) {}

$options = array_replace_recursive(self::$defaults, $options);
$method = 'get' . ucfirst(strtolower(self::$method));
Expand Down
5 changes: 2 additions & 3 deletions system/src/Grav/Common/Utils.php
Expand Up @@ -218,10 +218,9 @@ public static function download($file, $force_download = true)
$file_parts = pathinfo($file);
$filesize = filesize($file);

// check if this function is available, if so use it to stop any timeouts
if (function_exists('set_time_limit')) {
try {
set_time_limit(0);
}
} catch (\Exception $e) {}

ignore_user_abort(false);

Expand Down

2 comments on commit ae39aab

@vladdu
Copy link

@vladdu vladdu commented on ae39aab Nov 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it only works completely if even the 'if'-s are inside the try.

Thanks!

@flaviocopes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.