Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2018-11-27 07:59:08 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2018-11-27 07:59:08 +0300
commitaa977ef9b0f29eec69eaff024cac73f6d0d6ed7e (patch)
tree46d08853a3ffad5ad3ece39586c3250382b3f148 /plugins/Installation
parent4a556e080361ced25e0f3988feb983b027093cd7 (diff)
During installation allow to prefill DB form from environment variables (#13676)
Diffstat (limited to 'plugins/Installation')
-rw-r--r--plugins/Installation/FormDatabaseSetup.php24
1 files changed, 19 insertions, 5 deletions
diff --git a/plugins/Installation/FormDatabaseSetup.php b/plugins/Installation/FormDatabaseSetup.php
index 47ba67bb11..74de2535b4 100644
--- a/plugins/Installation/FormDatabaseSetup.php
+++ b/plugins/Installation/FormDatabaseSetup.php
@@ -80,12 +80,26 @@ class FormDatabaseSetup extends QuickForm2
$defaultDatabaseType = Config::getInstance()->database['type'];
$this->addElement( 'hidden', 'type')->setLabel('Database engine');
+
+ $defaults = array(
+ 'host' => '127.0.0.1',
+ 'type' => $defaultDatabaseType,
+ 'tables_prefix' => 'matomo_',
+ );
+
+ $defaultsEnvironment = array('host', 'adapter', 'tables_prefix', 'username', 'password', 'dbname');
+ foreach ($defaultsEnvironment as $name) {
+ $envName = 'DATABASE_' . strtoupper($name); // fyi getenv is case insensitive
+ $envNameMatomo = 'MATOMO_' . $envName;
+ if (getenv($envNameMatomo)) {
+ $defaults[$name] = getenv($envNameMatomo);
+ } elseif (getenv($envName)) {
+ $defaults[$name] = getenv($envName);
+ }
+ }
+
// default values
- $this->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
- 'host' => '127.0.0.1',
- 'type' => $defaultDatabaseType,
- 'tables_prefix' => 'matomo_',
- )));
+ $this->addDataSource(new HTML_QuickForm2_DataSource_Array($defaults));
}
/**