diff --git a/system/src/Grav/Common/GPM/Response.php b/system/src/Grav/Common/GPM/Response.php index 08b0baeb1..fcaed82b3 100644 --- a/system/src/Grav/Common/GPM/Response.php +++ b/system/src/Grav/Common/GPM/Response.php @@ -78,8 +78,11 @@ class Response throw new \RuntimeException('Could not start an HTTP request. `allow_url_open` is disabled and `cURL` is not available'); } + // check if this function is available, if so use it to stop any timeouts try { - set_time_limit(0); + if (!Utils::isFunctionDisabled('set_time_limit') && !ini_get('safe_mode') && function_exists('set_time_limit')) { + set_time_limit(0); + } } catch (\Exception $e) {} $options = array_replace_recursive(self::$defaults, $options); diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index ead9e627d..815959927 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -218,8 +218,11 @@ abstract class Utils $file_parts = pathinfo($file); $filesize = filesize($file); + // check if this function is available, if so use it to stop any timeouts try { - set_time_limit(0); + if (!Utils::isFunctionDisabled('set_time_limit') && !ini_get('safe_mode') && function_exists('set_time_limit')) { + set_time_limit(0); + } } catch (\Exception $e) {} ignore_user_abort(false); @@ -410,6 +413,25 @@ abstract class Utils } } + /** + * Get value of an array using dot notation + */ + public static function resolve(array $array, $path, $default = null) + { + $current = $array; + $p = strtok($path, '.'); + + while ($p !== false) { + if (!isset($current[$p])) { + return $default; + } + $current = $current[$p]; + $p = strtok('.'); + } + + return $current; + } + /** * Checks if a value is positive *