diff --git a/LibreNMS/DB/Eloquent.php b/LibreNMS/DB/Eloquent.php index 6513176cb8..1fa591466e 100644 --- a/LibreNMS/DB/Eloquent.php +++ b/LibreNMS/DB/Eloquent.php @@ -36,7 +36,7 @@ class Eloquent /** @var Capsule static reference to capsule */ private static $capsule; - public static function boot($options = []) + public static function boot() { // boot Eloquent outside of Laravel if (!Laravel::isBooted() && is_null(self::$capsule)) { @@ -47,24 +47,6 @@ class Eloquent $db_config = include($install_dir . '/config/database.php'); $settings = $db_config['connections'][$db_config['default']]; - // legacy connection override - if (!empty($options)) { - $fields = [ - 'host' => 'db_host', - 'port' => 'db_port', - 'database' => 'db_name', - 'username' => 'db_user', - 'password' => 'db_pass', - 'unix_socket' => 'db_socket', - ]; - - foreach ($fields as $new => $old) { - if (isset($options[$old])) { - $settings[$new] = $options[$old]; - } - } - } - self::$capsule = new Capsule; self::$capsule->addConnection($settings); self::$capsule->setEventDispatcher(new Dispatcher()); diff --git a/includes/dbFacile.php b/includes/dbFacile.php index 1160187765..7e5262f323 100644 --- a/includes/dbFacile.php +++ b/includes/dbFacile.php @@ -52,11 +52,26 @@ function dbConnect($db_host = null, $db_user = '', $db_pass = '', $db_name = '', } try { - if (is_null($db_host) && empty($db_name)) { - Eloquent::boot(); - } else { - Eloquent::boot(get_defined_vars()); + if (!is_null($db_host) || !empty($db_name)) { + // legacy connection override + \Config::set('database.connections.setup', [ + "driver" => "mysql", + "host" => $db_host, + "port" => $db_port, + "database" => $db_name, + "username" => $db_user, + "password" => $db_pass, + "unix_socket" => $db_socket, + "charset" => "utf8", + "collation" => "utf8_unicode_ci", + "prefix" => "", + "strict" => true, + "engine" => null + ]); + \Config::set('database.default', 'setup'); } + + Eloquent::boot(); } catch (PDOException $e) { throw new DatabaseConnectException($e->getMessage(), $e->getCode(), $e); }