Fixed errors in setup performances

Former-commit-id: 1eb48c00f527f43504a41aea8b352f30792e080b
This commit is contained in:
Daniel Barbero 2019-02-14 16:31:19 +01:00
parent 0fb61444f6
commit d9ba3af358

View File

@ -63,76 +63,85 @@ if ($update_config == 1 && $config['history_db_enabled'] == 1) {
$historical_event_purge = get_parameter('historical_event_purge', 0); $historical_event_purge = get_parameter('historical_event_purge', 0);
$historical_string_purge = get_parameter('historical_string_purge', 0); $historical_string_purge = get_parameter('historical_string_purge', 0);
$config_history = mysql_db_process_sql( $history_connect = @mysql_db_process_sql(
'SELECT * FROM tconfig', 'SELECT 1 FROM tconfig',
'affected_rows', 'affected_rows',
$config['history_db_connection'], $config['history_db_connection'],
false false
); );
if (!$config_history) { $config_history = false;
$sql = "INSERT INTO tconfig (token, `value`) VALUES if ($history_connect !== false) {
('days_purge', ".$historical_days_purge."), $config_history = mysql_db_process_sql(
('days_compact', ".$historical_days_compact."), 'SELECT * FROM tconfig',
('step_compact', ".$historical_step_compact."), 'affected_rows',
('event_purge', ".$historical_event_purge."), $config['history_db_connection'],
('string_purge', ".$historical_string_purge."), false
('history_db_enabled', 0)"; );
mysql_db_process_sql( if (!$config_history) {
$sql, $sql = "INSERT INTO tconfig (token, `value`) VALUES
'insert_id', ('days_purge', ".$historical_days_purge."),
$config['history_db_connection'], ('days_compact', ".$historical_days_compact."),
false ('step_compact', ".$historical_step_compact."),
); ('event_purge', ".$historical_event_purge."),
} else { ('string_purge', ".$historical_string_purge."),
$sql = 'UPDATE tconfig SET `value` = '.$historical_days_purge." WHERE token = 'days_purge'"; ('history_db_enabled', 0)";
mysql_db_process_sql(
$sql, mysql_db_process_sql(
'update_id', $sql,
$config['history_db_connection'], 'insert_id',
false $config['history_db_connection'],
); false
$sql = 'UPDATE tconfig SET `value` = '.$historical_days_compact." WHERE token = 'days_compact'"; );
mysql_db_process_sql( } else {
$sql, $sql = 'UPDATE tconfig SET `value` = '.$historical_days_purge." WHERE token = 'days_purge'";
'update_id', mysql_db_process_sql(
$config['history_db_connection'], $sql,
false 'update_id',
); $config['history_db_connection'],
$sql = 'UPDATE tconfig SET `value` = '.$historical_step_compact." WHERE token = 'step_compact'"; false
mysql_db_process_sql( );
$sql, $sql = 'UPDATE tconfig SET `value` = '.$historical_days_compact." WHERE token = 'days_compact'";
'update_id', mysql_db_process_sql(
$config['history_db_connection'], $sql,
false 'update_id',
); $config['history_db_connection'],
$sql = 'UPDATE tconfig SET `value` = '.$historical_event_purge." WHERE token = 'event_purge'"; false
mysql_db_process_sql( );
$sql, $sql = 'UPDATE tconfig SET `value` = '.$historical_step_compact." WHERE token = 'step_compact'";
'update_id', mysql_db_process_sql(
$config['history_db_connection'], $sql,
false 'update_id',
); $config['history_db_connection'],
$sql = 'UPDATE tconfig SET `value` = '.$historical_string_purge." WHERE token = 'string_purge'"; false
mysql_db_process_sql( );
$sql, $sql = 'UPDATE tconfig SET `value` = '.$historical_event_purge." WHERE token = 'event_purge'";
'update_id', mysql_db_process_sql(
$config['history_db_connection'], $sql,
false 'update_id',
); $config['history_db_connection'],
$sql = "UPDATE tconfig SET `value` = 0 WHERE token = 'history_db_enabled'"; false
mysql_db_process_sql( );
$sql, $sql = 'UPDATE tconfig SET `value` = '.$historical_string_purge." WHERE token = 'string_purge'";
'update_id', mysql_db_process_sql(
$config['history_db_connection'], $sql,
false 'update_id',
); $config['history_db_connection'],
false
);
$sql = "UPDATE tconfig SET `value` = 0 WHERE token = 'history_db_enabled'";
mysql_db_process_sql(
$sql,
'update_id',
$config['history_db_connection'],
false
);
}
} }
} }
} }
$table_status = new StdClass(); $table_status = new StdClass();
$table_status->width = '100%'; $table_status->width = '100%';
$table_status->class = 'databox filters'; $table_status->class = 'databox filters';
@ -147,6 +156,7 @@ $sql = "SELECT UNIX_TIMESTAMP(NOW()) - `value` AS updated_at
$time_pandora_db_active = db_get_sql($sql); $time_pandora_db_active = db_get_sql($sql);
if ($time_pandora_db_active < SECONDS_12HOURS) { if ($time_pandora_db_active < SECONDS_12HOURS) {
$table_status->data[0][0] = html_print_image( $table_status->data[0][0] = html_print_image(
'images/dot_green.png', 'images/dot_green.png',
@ -168,11 +178,6 @@ $table_status->data[0][0] .= human_time_description_raw(
$table_status->data[0][0] .= ' '.__('ago').'.'; $table_status->data[0][0] .= ' '.__('ago').'.';
$table_status->data[0][0] .= ui_print_help_tip(
__('WIP'),
true
);
if ($config['history_db_enabled'] == 1) { if ($config['history_db_enabled'] == 1) {
if (! isset($config['history_db_connection']) if (! isset($config['history_db_connection'])
|| $config['history_db_connection'] === false || $config['history_db_connection'] === false
@ -187,13 +192,23 @@ if ($config['history_db_enabled'] == 1) {
); );
} }
if ($config['history_db_connection'] !== false) { $history_connect = @mysql_db_process_sql(
$time_pandora_db_history = mysql_db_process_sql( 'SELECT 1 FROM tconfig',
$sql, 'affected_rows',
'insert_id', $config['history_db_connection'],
$config['history_db_connection'], false
false );
);
$time_pandora_db_history = false;
if ($history_connect !== false) {
if ($config['history_db_connection'] !== false) {
$time_pandora_db_history = mysql_db_process_sql(
$sql,
'insert_id',
$config['history_db_connection'],
false
);
}
} }
if ($time_pandora_db_history !== false if ($time_pandora_db_history !== false
@ -220,11 +235,6 @@ if ($config['history_db_enabled'] == 1) {
} else { } else {
$table_status->data[1][0] .= __('not executed'); $table_status->data[1][0] .= __('not executed');
} }
$table_status->data[1][0] .= ui_print_help_tip(
__('WIP'),
true
);
} }
@ -395,21 +405,33 @@ if ($config['history_db_enabled'] == 1) {
); );
} }
if ($config['history_db_connection'] != false) { $history_connect = @mysql_db_process_sql(
$config_history_array = mysql_db_process_sql( 'SELECT 1 FROM tconfig',
'SELECT * FROM tconfig', 'affected_rows',
'affected_rows', $config['history_db_connection'],
$config['history_db_connection'], false
false );
);
$config_history = false; $config_history = false;
if ($history_connect !== false) {
if ($config['history_db_connection'] != false) {
$config_history_array = mysql_db_process_sql(
'SELECT * FROM tconfig',
'affected_rows',
$config['history_db_connection'],
false
);
if (isset($config_history_array) && is_array($config_history_array)) { if (isset($config_history_array) && is_array($config_history_array)) {
foreach ($config_history_array as $key => $value) { foreach ($config_history_array as $key => $value) {
$config_history[$value['token']] = $value['value']; $config_history[$value['token']] = $value['value'];
}
} }
} }
} else {
echo ui_print_error_message(
__('The tconfig table does not exist in the bbdd')
);
} }
if ($config_history === false) { if ($config_history === false) {