diff --git a/pandora_console/extras/mr/48.sql b/pandora_console/extras/mr/48.sql index b65846c487..23ea069531 100644 --- a/pandora_console/extras/mr/48.sql +++ b/pandora_console/extras/mr/48.sql @@ -25,7 +25,9 @@ CREATE TABLE IF NOT EXISTS `tsync_queue` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -SOURCE './procedures/updateSnmpAlerts.sql'; +LOAD ./procedures/updateSnmpAlerts.sql; +CALL updateSnmpAlerts(); +DROP PROCEDURE updateSnmpAlerts; UPDATE `tlink` SET `link` = 'https://pandorafms.com/manual/' WHERE `id_link` = 0000000001; @@ -38,7 +40,7 @@ UPDATE `tuser_task_scheduled` SET `args`= REPLACE(`args`, 's:15:"first_execution"', 'i:2;s:0:"";i:7;s:3:"PDF";s:15:"first_execution"') WHERE `id_user_task` = 2; -UPDATE `tconfig` SET `value` = 0 WHERE `token` = `centralized_management`; +UPDATE `tconfig` SET `value` = 0 WHERE `token` = 'centralized_management'; DELETE ta FROM `tagente` ta LEFT JOIN `tgrupo` tg on ta.`id_grupo` = tg.`id_grupo` WHERE tg.`id_grupo` IS NULL; diff --git a/pandora_console/extras/mr/procedures/updateSnmpAlerts.sql b/pandora_console/extras/mr/procedures/updateSnmpAlerts.sql index 0193b78a16..5fed73fdf9 100644 --- a/pandora_console/extras/mr/procedures/updateSnmpAlerts.sql +++ b/pandora_console/extras/mr/procedures/updateSnmpAlerts.sql @@ -1,4 +1,3 @@ -DELIMITER // CREATE PROCEDURE updateSnmpAlerts() BEGIN DECLARE tokenId INT DEFAULT 0; @@ -33,7 +32,4 @@ BEGIN UPDATE tconfig SET value = 1 WHERE token = 'update_snmp_alerts_procedure_already_run'; END IF; END IF; -END// -DELIMITER ; -CALL updateSnmpAlerts(); -DROP PROCEDURE updateSnmpAlerts; \ No newline at end of file +END \ No newline at end of file diff --git a/pandora_console/godmode/um_client/lib/UpdateManager/Client.php b/pandora_console/godmode/um_client/lib/UpdateManager/Client.php index b427353a90..d324df1120 100644 --- a/pandora_console/godmode/um_client/lib/UpdateManager/Client.php +++ b/pandora_console/godmode/um_client/lib/UpdateManager/Client.php @@ -941,6 +941,15 @@ class Client $queries = preg_split("/(;\n)|(;\n\r)/", $sql); foreach ($queries as $query) { if (empty($query) !== true) { + if (preg_match('/^\s*LOAD\s+(.*)$/i', $query, $matches) > 0) { + $filepath = dirname($mr_file).'/'.$matches[1]; + if (file_exists($filepath) === true) { + $query = file_get_contents($filepath); + } else { + throw new \Exception('Cannot load file: '.$filepath); + } + } + if ($dbh->query($query) === false) { // 1022: Duplicate key in table. // 1050: Table already defined.