Fix: Recreate disconnected connections when being retrieved (#19)

This commit is contained in:
Namoshek 2022-01-08 14:23:13 +01:00 committed by GitHub
parent 9e69fb1e45
commit 7dfaac06e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -60,6 +60,12 @@ class ConnectionManager
$name = $this->defaultConnection; $name = $this->defaultConnection;
} }
// Remove the connection if it is in a disconnected state.
// Doing this instead of simply reconnecting ensures the caller will get a fresh connection.
if (array_key_exists($name, $this->connections) && !$this->connections[$name]->isConnected()) {
unset($this->connections[$name]);
}
if (!array_key_exists($name, $this->connections)) { if (!array_key_exists($name, $this->connections)) {
$this->connections[$name] = $this->createConnection($name); $this->connections[$name] = $this->createConnection($name);
} }