From 49451b26817ba0d50121dc84a1bd0df5902906f9 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Tue, 7 May 2024 09:48:35 +0000 Subject: [PATCH] fixes #4123 Closes #4123 Merge request studip/studip!2968 --- docker/studip/config_local.php | 64 +++++++++++----------------------- tests/configuration.php | 22 ++++++++---- 2 files changed, 36 insertions(+), 50 deletions(-) diff --git a/docker/studip/config_local.php b/docker/studip/config_local.php index 010ff664318..63029e7fe65 100644 --- a/docker/studip/config_local.php +++ b/docker/studip/config_local.php @@ -1,49 +1,27 @@ <?php -/*basic settings for Stud.IP ----------------------------------------------------------------- -you find here the basic system settings. You shouldn't have to touch much of them... -please note the CONFIG.INC.PHP for the indivual settings of your installation!*/ - -namespace Studip { - //const ENV = 'development'; - define ('ENV', getenv('ENV') ?? 'development'); -} - -namespace { - /*settings for database access - ---------------------------------------------------------------- - please fill in your database connection settings. - */ +define ('Studip\\ENV', $_ENV['ENV'] ?? 'development'); - // default Stud.IP database (DB_Seminar) - $DB_STUDIP_HOST = getenv('MYSQL_HOST'); - $DB_STUDIP_USER = getenv('MYSQL_USER'); - $DB_STUDIP_PASSWORD = getenv('MYSQL_PASSWORD'); - $DB_STUDIP_DATABASE = getenv('MYSQL_DATABASE'); - $MAIL_TRANSPORT = getenv('MAIL_TRANSPORT'); +error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); - /*URL - ---------------------------------------------------------------- - customize if automatic detection fails, e.g. when installation is hidden - behind a proxy - */ - //$CANONICAL_RELATIVE_PATH_STUDIP = '/'; - //$ABSOLUTE_URI_STUDIP = 'https://www.studip.de/'; - //$ASSETS_URL = 'https://www.studip.de/assets/'; - - // Set proxy url - if ($PROXY_URL = getenv('PROXY_URL')) { - $ABSOLUTE_URI_STUDIP = $PROXY_URL; - $ASSETS_URL = $PROXY_URL.'/assets/'; - unset($PROXY_URL); - } +/*URL +---------------------------------------------------------------- +customize if automatic detection fails, e.g. when installation is hidden +behind a proxy +*/ +//$CANONICAL_RELATIVE_PATH_STUDIP = '/'; +//$ABSOLUTE_URI_STUDIP = 'https://www.studip.de/'; +//$ASSETS_URL = 'https://www.studip.de/assets/'; - // Use autoproxy - if (getenv('AUTO_PROXY')) { - $ABSOLUTE_URI_STUDIP = $_SERVER['HTTP_X_FORWARDED_PROTO'].'://'.$_SERVER['HTTP_X_FORWARDED_HOST'].'/'; - $ASSETS_URL = $ABSOLUTE_URI_STUDIP.'/assets/'; - } - $MAIL_TRANSPORT = getenv('STUDIP_MAIL_TRANSPORT'); +// Set proxy url +if (isset($_ENV['PROXY_URL'])) { + $ABSOLUTE_URI_STUDIP = $_ENV['PROXY_URL']; + $ASSETS_URL = $_ENV['PROXY_URL'].'/assets/'; +} - $CONTENT_LANGUAGES['en_GB'] = ['picture' => 'lang_en.gif', 'name' => 'English']; +// Use autoproxy +if (isset($_ENV['AUTO_PROXY'])) { + $ABSOLUTE_URI_STUDIP = $_SERVER['HTTP_X_FORWARDED_PROTO'].'://'.$_SERVER['HTTP_X_FORWARDED_HOST'].'/'; + $ASSETS_URL = $ABSOLUTE_URI_STUDIP.'/assets/'; } + +$CONTENT_LANGUAGES['en_GB'] = ['picture' => 'lang_en.gif', 'name' => 'English']; diff --git a/tests/configuration.php b/tests/configuration.php index f2ea4611014..523229fe25a 100644 --- a/tests/configuration.php +++ b/tests/configuration.php @@ -1,11 +1,19 @@ <?php -return (function ($filename) { - if (file_exists($filename)) { - require_once $filename; - - return compact('DB_STUDIP_HOST', 'DB_STUDIP_USER', 'DB_STUDIP_PASSWORD', 'DB_STUDIP_DATABASE'); +return (function (string ...$filenames) { + foreach ($filenames as $filename) { + if (file_exists($filename)) { + require_once $filename; + } } - return []; -})(dirname(__DIR__).'/config/config_local.inc.php'); + return array_filter([ + 'DB_STUDIP_HOST' => $DB_STUDIP_HOST ?? null, + 'DB_STUDIP_USER' => $DB_STUDIP_USER ?? null, + 'DB_STUDIP_PASSWORD' => $DB_STUDIP_PASSWORD ?? null, + 'DB_STUDIP_DATABASE' => $DB_STUDIP_DATABASE ?? null, + ]); +})( + dirname(__DIR__).'/config/config_defaults.inc.php', + dirname(__DIR__).'/config/config_local.inc.php' +); -- GitLab