From bac282d3abab5c919ec543bc84a2ab12ab1e8a4f Mon Sep 17 00:00:00 2001 From: Kevin Dees Date: Thu, 4 Aug 2022 10:21:35 -0400 Subject: [PATCH] fix bug --- src/Database/Connection.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Database/Connection.php b/src/Database/Connection.php index c80336a..a1664b6 100644 --- a/src/Database/Connection.php +++ b/src/Database/Connection.php @@ -41,14 +41,14 @@ public function add(string $name, \wpdb $wpdb) } /** - * @param string $name + * @param null|string $name * @return $this */ - public function addFromConfig(string $name, ?array $config = null) + public function addFromConfig(?string $name, ?array $config = null) { - if(is_null($config)) { + if(is_null($config) || is_null($name)) { $drivers = Config::getFromContainer()->locate('database.drivers'); - $config = $drivers[$name]; + $config = $drivers[$name] ?? Config::getFromContainer()->locate('database.default'); } /** @var DatabaseConnector $connector */ @@ -71,10 +71,10 @@ public function getOrAddFromConfig(string $name, ?array $config = null) } /** - * @param string $name + * @param ?string $name * @return \wpdb */ - public function get(string $name, ?string $fallback = null) + public function get(?string $name, ?string $fallback = null) { if(!array_key_exists($name, $this->connections) && is_null($fallback)) { $this->addFromConfig($name); @@ -111,7 +111,7 @@ public function close(string $name) */ public function default() { - $default = Config::getFromContainer()->locate('database.default'); + $default = Config::getFromContainer()->locate('database.default', 'wp'); return $this->get($default); }