#12994 fixed message error sql in history db

This commit is contained in:
Daniel Cebrian 2024-03-07 13:28:34 +01:00
parent a5eec87d47
commit 1125f64e89
5 changed files with 27 additions and 9 deletions

View File

@ -2,7 +2,7 @@
echo '<script src="'.ui_get_full_url('include/javascript/jquery.current.js', false, false, false).'" type="text/javascript"></script>'; echo '<script src="'.ui_get_full_url('include/javascript/jquery.current.js', false, false, false).'" type="text/javascript"></script>';
$message = ''; $message = '';
$config['ignore_cache_translate'] = true;
if ($config['history_db_connection'] === false) { if ($config['history_db_connection'] === false) {
$message = __('Failure to connect to historical database, please check the configuration or contact system administrator if you need assistance.'); $message = __('Failure to connect to historical database, please check the configuration or contact system administrator if you need assistance.');
} else { } else {

View File

@ -314,6 +314,13 @@ class ConsoleSupervisor
*/ */
$this->checkTotalModulesByAgent(); $this->checkTotalModulesByAgent();
/*
* Check connection with historical DB (if enabled).
* NOTIF.HISTORYDB
*/
$this->checkPandoraHistoryDB();
} }
@ -2041,7 +2048,7 @@ class ConsoleSupervisor
'title' => __('Historical database not available'), 'title' => __('Historical database not available'),
'message' => __('Historical database is enabled, though not accessible with the current configuration.'), 'message' => __('Historical database is enabled, though not accessible with the current configuration.'),
'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup&section=hist_db', 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup&section=hist_db',
'icon_notification' => self::ICON_QUESTION, 'icon_notification' => self::ICON_ERROR,
] ]
); );
} else { } else {

View File

@ -33,7 +33,8 @@ function mysql_connect_db(
$port=null, $port=null,
$charset=null, $charset=null,
$ssl=null, $ssl=null,
$verify=null $verify=null,
$history=false
) { ) {
global $config; global $config;
@ -83,11 +84,17 @@ function mysql_connect_db(
try { try {
$connect_id = mysqli_connect($host, $user, $pass, $db, $port); $connect_id = mysqli_connect($host, $user, $pass, $db, $port);
if (mysqli_connect_errno() > 0) { if (mysqli_connect_errno() > 0) {
include 'general/mysqlerr.php'; if ($history === false) {
include 'general/mysqlerr.php';
}
return false; return false;
} }
} catch (\mysqli_sql_exception $e) { } catch (\mysqli_sql_exception $e) {
include 'general/mysqlerr.php'; if ($history === false) {
include 'general/mysqlerr.php';
}
return false; return false;
} }
@ -156,7 +163,7 @@ function mysql_db_get_all_rows_sql($sql, $search_history_db=false, $cache=true,
// Connect to the history DB // Connect to the history DB
if (!isset($config['history_db_connection']) || $config['history_db_connection'] === false) { if (!isset($config['history_db_connection']) || $config['history_db_connection'] === false) {
$config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false); $config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false, null, true);
} }
if ($config['history_db_connection'] !== false) { if ($config['history_db_connection'] !== false) {

View File

@ -6904,7 +6904,7 @@ function get_defined_translation($string)
} }
} }
if (is_array($cache_translation) === true && count($cache_translation) === 0) { if ($config['ignore_cache_translate'] !== true && is_array($cache_translation) === true && count($cache_translation) === 0) {
$cache_translation_all = db_get_all_rows_sql( $cache_translation_all = db_get_all_rows_sql(
sprintf( sprintf(
'SELECT translation, string 'SELECT translation, string

View File

@ -87,7 +87,8 @@ function db_connect(
$pass=null, $pass=null,
$port=null, $port=null,
$critical=true, $critical=true,
$charset=null $charset=null,
$history=false,
) { ) {
global $config; global $config;
static $error = 0; static $error = 0;
@ -100,7 +101,10 @@ function db_connect(
$user, $user,
$pass, $pass,
$port, $port,
$charset $charset,
null,
null,
$history,
); );
break; break;