public function getDatabaseConfig($request, $databaseClasses, $realPassword = true)
    {
        // Get config from request
        if (isset($request['db']['type'])) {
            $type = $request['db']['type'];
            if (isset($request['db'][$type])) {
                $config = $request['db'][$type];
                // The posted placeholder must be substituted with the real password
                if (isset($config['password']) && $config['password'] === Installer::PASSWORD_PLACEHOLDER) {
                    $config['password'] = Environment::getEnv('SS_DATABASE_PASSWORD') ?: '';
                }
                return array_merge([ 'type' => $type ], $config);
            }
        }

        // Guess database config
        return [
            'type' => $this->getDatabaseClass($databaseClasses),
            'server' => Environment::getEnv('SS_DATABASE_SERVER') ?: 'localhost',
            'username' => Environment::getEnv('SS_DATABASE_USERNAME') ?: 'root',
            'password' => $realPassword
                ? (Environment::getEnv('SS_DATABASE_PASSWORD') ?: '')
                : Installer::PASSWORD_PLACEHOLDER, // Avoid password disclosure
            'database' => Environment::getEnv('SS_DATABASE_NAME') ?: 'SS_mysite',
            'path' => Environment::getEnv('SS_DATABASE_PATH')
                ?: Environment::getEnv('SS_SQLITE_DATABASE_PATH') // sqlite compat
                ?: null,
            'key' => Environment::getEnv('SS_DATABASE_KEY')
                ?: Environment::getEnv('SS_SQLITE_DATABASE_KEY') // sqlite compat
                ?: null,
        ];
    }