]> git.mxchange.org Git - friendica.git/commitdiff
Fixing PHP Fatal Error for Database-Reconnects with PDO
authorPhilipp Holzer <admin+github@philipp.info>
Tue, 27 Aug 2019 23:40:02 +0000 (01:40 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Tue, 27 Aug 2019 23:40:34 +0000 (01:40 +0200)
src/Database/Database.php

index d3ec4d585a1f71a3606d47c2af9036723be74fad..d13b52848d311ff0c49e305bd482c7937e3f0ebb 100644 (file)
@@ -4,6 +4,7 @@ namespace Friendica\Database;
 
 use Friendica\Core\Config\Cache\ConfigCache;
 use Friendica\Core\System;
+use Friendica\Network\HTTPException\InternalServerErrorException;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Profiler;
 use mysqli;
@@ -126,7 +127,7 @@ class Database
                                $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                                $this->connected = true;
                        } 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"
                $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) {
                        case 'pdo':
                                // If there are no arguments we use "query"