]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/Database.php
Merge pull request #8804 from MrPetovan/bug/warnings
[friendica.git] / src / Database / Database.php
index 4944529744c9b16a5fe57946517cf31c0461e974..897845ce0c8d6ba700c1a794d4149c99f0e1263c 100644 (file)
@@ -135,8 +135,9 @@ class Database
                }
 
                $this->emulate_prepares = (bool)$this->configCache->get('database', 'emulate_prepares');
+               $this->pdo_emulate_prepares = (bool)$this->configCache->get('database', 'pdo_emulate_prepares');
 
-               if (class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
+               if (!$this->configCache->get('database', 'disable_pdo') && class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
                        $this->driver = 'pdo';
                        $connect      = "mysql:host=" . $server . ";dbname=" . $db;
 
@@ -150,7 +151,7 @@ class Database
 
                        try {
                                $this->connection = @new PDO($connect, $user, $pass);
-                               $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+                               $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->pdo_emulate_prepares);
                                $this->connected = true;
                        } catch (PDOException $e) {
                                $this->connected = false;
@@ -318,7 +319,7 @@ class Database
                }
 
                $watchlist = explode(',', $this->configCache->get('system', 'db_log_index_watch'));
-               $blacklist = explode(',', $this->configCache->get('system', 'db_log_index_blacklist'));
+               $denylist = explode(',', $this->configCache->get('system', 'db_log_index_denylist'));
 
                while ($row = $this->fetch($r)) {
                        if ((intval($this->configCache->get('system', 'db_loglimit_index')) > 0)) {
@@ -332,7 +333,7 @@ class Database
                                $log = true;
                        }
 
-                       if (in_array($row['key'], $blacklist) || ($row['key'] == "")) {
+                       if (in_array($row['key'], $denylist) || ($row['key'] == "")) {
                                $log = false;
                        }
 
@@ -348,7 +349,7 @@ class Database
        }
 
        /**
-        * Removes every not whitelisted character from the identifier string
+        * Removes every not allowlisted character from the identifier string
         *
         * @param string $identifier
         *
@@ -978,7 +979,7 @@ class Database
         * @return boolean was the insert successful?
         * @throws \Exception
         */
-       public function insert($table, $param, $on_duplicate_update = false)
+       public function insert($table, array $param, bool $on_duplicate_update = false)
        {
                if (empty($table) || empty($param)) {
                        $this->logger->info('Table and fields have to be set');
@@ -1046,7 +1047,7 @@ class Database
                $success = $this->e("LOCK TABLES " . DBA::buildTableString($table) . " WRITE");
 
                if ($this->driver == 'pdo') {
-                       $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+                       $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->pdo_emulate_prepares);
                }
 
                if (!$success) {
@@ -1079,7 +1080,7 @@ class Database
                $success = $this->e("UNLOCK TABLES");
 
                if ($this->driver == 'pdo') {
-                       $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+                       $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->pdo_emulate_prepares);
                        $this->e("SET autocommit=1");
                } else {
                        $this->connection->autocommit(true);