From bbe6554bb0b748f8e80771b50f4fc77343c1b93f Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 4 May 2023 17:48:13 +0200 Subject: [PATCH 1/2] Introduce settings for overriding php.ini values --- src/App.php | 12 ++++++++---- static/defaults.config.php | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/App.php b/src/App.php index 0d860638b1..3d650abc1a 100644 --- a/src/App.php +++ b/src/App.php @@ -335,7 +335,14 @@ class App */ protected function load(DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition) { - set_time_limit(0); + if ($this->config->get('system', 'ini_max_execution_time') !== false) { + set_time_limit((int)$this->config->get('system', 'ini_max_execution_time')); + } + + // This has to be quite large to deal with embedded private photos + if ($this->config->get('system', 'ini_pcre_backtrack_limit') !== false) { + ini_set('pcre.backtrack_limit', (int)$this->config->get('system', 'ini_pcre_backtrack_limit')); + } // Normally this constant is defined - but not if "pcntl" isn't installed if (!defined('SIGTERM')) { @@ -345,9 +352,6 @@ class App // Ensure that all "strtotime" operations do run timezone independent date_default_timezone_set('UTC'); - // This has to be quite large to deal with embedded private photos - ini_set('pcre.backtrack_limit', 500000); - set_include_path( get_include_path() . PATH_SEPARATOR . $this->getBasePath() . DIRECTORY_SEPARATOR . 'include' . PATH_SEPARATOR diff --git a/static/defaults.config.php b/static/defaults.config.php index 7e699fad71..2c2175b005 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -341,6 +341,14 @@ return [ // Resolve IPV4 addresses only. Don't resolve to IPV6. 'ipv4_resolve' => false, + // ini_max_execution_time (False|Integer) + // Set the number of seconds a script is allowed to run. Default unlimited for Friendica, False means disabled + 'ini_max_execution_time' => 0, + + // ini_pcre_backtrack_limit (False|Integer) + // This has to be quite large to deal with embedded private photos. False means disabled + 'ini_pcre_backtrack_limit' => 500000, + // invitation_only (Boolean) // If set true registration is only possible after a current member of the node has sent an invitation. 'invitation_only' => false, From 948217da510c4d1d00ea718c98e4091bcab731e2 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 4 May 2023 18:27:44 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Hypolite Petovan --- src/App.php | 1 - static/defaults.config.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/App.php b/src/App.php index 3d650abc1a..495cfb8b0a 100644 --- a/src/App.php +++ b/src/App.php @@ -339,7 +339,6 @@ class App set_time_limit((int)$this->config->get('system', 'ini_max_execution_time')); } - // This has to be quite large to deal with embedded private photos if ($this->config->get('system', 'ini_pcre_backtrack_limit') !== false) { ini_set('pcre.backtrack_limit', (int)$this->config->get('system', 'ini_pcre_backtrack_limit')); } diff --git a/static/defaults.config.php b/static/defaults.config.php index 2c2175b005..d0b8262ac7 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -342,11 +342,11 @@ return [ 'ipv4_resolve' => false, // ini_max_execution_time (False|Integer) - // Set the number of seconds a script is allowed to run. Default unlimited for Friendica, False means disabled + // Set the number of seconds a script is allowed to run. Default unlimited for Friendica, false to use the system value. 'ini_max_execution_time' => 0, // ini_pcre_backtrack_limit (False|Integer) - // This has to be quite large to deal with embedded private photos. False means disabled + // This has to be quite large to deal with embedded private photos. False to use the system value. 'ini_pcre_backtrack_limit' => 500000, // invitation_only (Boolean)