From 24f7dbd420aceceeace7d1e0ed3141c6668cb47e Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 23 Aug 2018 14:50:19 +0200 Subject: [PATCH] added cache to function agents_get_all_groups_agent --- pandora_console/include/functions_agents.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 05652d3080..a9f5a12a0c 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2678,6 +2678,9 @@ function agents_generate_name ($alias, $address = '') { * @return Array with the main and secondary groups */ function agents_get_all_groups_agent ($id_agent, $group = false) { + // Cache the agent id groups + static $cache = array(); + if (isset($cache[$id_agent])) return $cache[$id_agent]; // Get the group if is not defined if ($group === false) $group = agents_get_agent_group($id_agent); @@ -2691,6 +2694,7 @@ function agents_get_all_groups_agent ($id_agent, $group = false) { // Add a list of groups $secondary_groups['plain'][] = $group; + $cache[$id_agent] = $secondary_groups['plain']; return $secondary_groups['plain']; }