Fixing PHP Fatal Error for Database-Reconnects with PDO
This commit is contained in:
parent
4733b1e5e0
commit
4b4dbd38d9
1 changed files with 6 additions and 1 deletions
|
@ -4,6 +4,7 @@ namespace Friendica\Database;
|
||||||
|
|
||||||
use Friendica\Core\Config\Cache\ConfigCache;
|
use Friendica\Core\Config\Cache\ConfigCache;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use mysqli;
|
use mysqli;
|
||||||
|
@ -126,7 +127,7 @@ class Database
|
||||||
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
/// @TODO At least log exception, don't ignore it!
|
$this->connected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,6 +485,10 @@ class Database
|
||||||
// We are having an own error logging in the function "e"
|
// We are having an own error logging in the function "e"
|
||||||
$called_from_e = ($called_from['function'] == 'e');
|
$called_from_e = ($called_from['function'] == 'e');
|
||||||
|
|
||||||
|
if (!isset($this->connection)) {
|
||||||
|
throw new InternalServerErrorException('The Connection is empty, although connected is set true.');
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->driver) {
|
switch ($this->driver) {
|
||||||
case 'pdo':
|
case 'pdo':
|
||||||
// If there are no arguments we use "query"
|
// If there are no arguments we use "query"
|
||||||
|
|
Loading…
Reference in a new issue