Allow to pass database credentials via env in WCFSetup
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 7 Aug 2015 23:30:24 +0000 (01:30 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 7 Aug 2015 23:30:24 +0000 (01:30 +0200)
wcfsetup/install/files/lib/system/WCFSetup.class.php

index cecd532ed9af1d3530bac8221ea6175bbc2b0618..598850a8b711b69e6ba78c6aea3ccd581a3948b7 100644 (file)
@@ -571,19 +571,29 @@ class WCFSetup extends WCF {
         */
        protected function configureDB() {
                $availableDBClasses = self::getAvailableDBClasses();
-               $dbHost = 'localhost';
-               $dbUser = 'root';
-               $dbPassword = '';
-               $dbName = 'wcf';
-               $dbNumber = 1;
-               $dbClass = '';
+               if (self::$developerMode && isset($_ENV['WCFSETUP_DBHOST']))  {
+                       $dbHost = $_ENV['WCFSETUP_DBHOST'];
+                       $dbUser = $_ENV['WCFSETUP_DBUSER'];
+                       $dbPassword = $_ENV['WCFSETUP_DBPASSWORD'];
+                       $dbName = $_ENV['WCFSETUP_DBNAME'];
+                       $dbNumber = 1;
+               }
+               else {
+                       $dbHost = 'localhost';
+                       $dbUser = 'root';
+                       $dbPassword = '';
+                       $dbName = 'wcf';
+                       $dbNumber = 1;
+                       $dbClass = '';
+               }
+               
                // set $dbClass to first item in $availableDBClasses
                foreach ($availableDBClasses as $dbClass) {
                        $dbClass = $dbClass['class'];
                        break;
                }
                
-               if (isset($_POST['send'])) {
+               if (isset($_POST['send']) || (self::$developerMode && isset($_ENV['WCFSETUP_DBHOST']))) {
                        if (isset($_POST['dbHost'])) $dbHost = $_POST['dbHost'];
                        if (isset($_POST['dbUser'])) $dbUser = $_POST['dbUser'];
                        if (isset($_POST['dbPassword'])) $dbPassword = $_POST['dbPassword'];