Introduce "static/env.config.php" for environment variable mapping to config cache entries

- Added new database.port config value (used for MYSQL_PORT)
- Removed now obsolete db environment variable functionality
- Added functionality to load env variables (overwrites DB based cached)
This commit is contained in:
Philipp Holzer 2020-10-06 20:06:52 +02:00
commit d39ee428f0
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
8 changed files with 93 additions and 8 deletions

View file

@ -32,6 +32,11 @@ return [
// Can contain the port number with the syntax "hostname:port".
'hostname' => '',
// port (Integer)
// Port of the database server.
// Can be used instead of adding a port number to the hostname
'port' => null,
// user (String)
// Database user name. Please don't use "root".
'username' => '',

View file

@ -75,13 +75,13 @@ return [
Util\ConfigFileLoader::class => [
'shared' => true,
'constructParams' => [
[Dice::INSTANCE => '$basepath'],
[Dice::INSTANCE => '$basepath']
],
],
Config\Cache::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createCache', [], Dice::CHAIN_CALL],
['createCache', [$_SERVER], Dice::CHAIN_CALL],
],
],
App\Mode::class => [
@ -105,7 +105,6 @@ return [
Database::class => [
'constructParams' => [
[Dice::INSTANCE => \Psr\Log\NullLogger::class],
$_SERVER,
],
],
/**

31
static/env.config.php Normal file
View file

@ -0,0 +1,31 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Main mapping table of environment variables to correct config values
*
*/
return [
'MYSQL_HOST' => ['database', 'hostname'],
'MYSQL_USERNAME' => ['database', 'username'],
'MYSQL_USER' => ['database', 'username'],
'MYSQL_PORT' => ['database', 'port'],
'MYSQL_PASSWORD' => ['database', 'password'],
'MYSQL_DATABASE' => ['database', 'database'],
];