From f688f73c46b1feb03a76cb833ba71837913a7d3a Mon Sep 17 00:00:00 2001
From: Daniel Barbero <daniel.barbero@artica.es>
Date: Wed, 21 Sep 2022 16:35:36 +0200
Subject: [PATCH] fixed historical database pandora_enterprise#8791

---
 pandora_console/include/lib/Core/Config.php       | 4 ++--
 pandora_console/include/lib/Core/DBMaintainer.php | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/pandora_console/include/lib/Core/Config.php b/pandora_console/include/lib/Core/Config.php
index 3030491202..dbed566598 100644
--- a/pandora_console/include/lib/Core/Config.php
+++ b/pandora_console/include/lib/Core/Config.php
@@ -73,7 +73,7 @@ final class Config
                 $config['history_db_user'],
                 io_output_password($config['history_db_pass']),
                 $config['history_db_name'],
-                $config['history_db_port']
+                (int) $config['history_db_port']
             );
 
             if ($rc === false) {
@@ -84,7 +84,7 @@ final class Config
                     $config['history_db_name'],
                     $config['history_db_user'],
                     io_output_password($config['history_db_pass']),
-                    $config['history_db_port'],
+                    (int) $config['history_db_port'],
                     false
                 );
             }
diff --git a/pandora_console/include/lib/Core/DBMaintainer.php b/pandora_console/include/lib/Core/DBMaintainer.php
index b1e43a7a70..35d3e969d6 100644
--- a/pandora_console/include/lib/Core/DBMaintainer.php
+++ b/pandora_console/include/lib/Core/DBMaintainer.php
@@ -135,7 +135,7 @@ final class DBMaintainer
         $this->user = $params['user'];
         $this->pass = io_output_password($params['pass']);
         $this->host = $params['host'];
-        $this->port = $params['port'];
+        $this->port = (int) $params['port'];
         $this->name = $params['name'];
         $this->charset = (isset($params['charset']) === true) ? $params['charset'] : '';
 
@@ -170,7 +170,10 @@ final class DBMaintainer
         if ($rc === false) {
             $this->dbh = null;
             $this->connected = false;
-            $this->lastError = __('Connection problems');
+            $this->lastError = __(
+                'Connection problems: %s',
+                mysqli_connect_error()
+            );
         } else {
             $dbc = new \mysqli(
                 $this->host,