Преглед на файлове

Little fix

Avoid this PHP warning:
Warning: Invalid argument supplied for foreach() in modules/cron/shared_cron_functions.php on line 211
Removed a couple of unused variables.
Moved two variables out of the loop since they will not change during the loop, so it does less queries to the database.
DieFeM преди 8 години
родител
ревизия
3f17ad9e09
променени са 1 файла, в които са добавени 4 реда и са изтрити 5 реда
  1. 4 5
      modules/cron/shared_cron_functions.php

+ 4 - 5
modules/cron/shared_cron_functions.php

@@ -201,13 +201,14 @@ function updateCronJobsToNewApi()
 		global $db;
 		$remote_servers = $db->getRemoteServers();
 		$regex = '/'.preg_quote('action=','/').'([a-zA-Z]+)'.preg_quote('&homeid=','/').'([0-9]+)'.preg_quote('&controlpass=','/').'([^"]+)/';
-		
+		$token = $db->getApiToken($_SESSION['user_id']);
+		$mod_key = '';
 		foreach($remote_servers as $remote_server)
 		{
 			$remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
 			$jobs = $remote->scheduler_list_tasks();
-			$token = $db->getApiToken($_SESSION['user_id']);
-			$mod_key = '';
+			if(!is_array($jobs))
+				continue;
 			foreach($jobs as $job_id => $job)
 			{
 				if(preg_match($regex, $job, $matches))
@@ -216,10 +217,8 @@ function updateCronJobsToNewApi()
 					$home_ip_ports = $db->getHomeIpPorts($home_id);
 					if(isset($home_ip_ports[0]))
 					{
-						$ip_id = $home_ip_ports[0]["ip_id"];
 						$port = $home_ip_ports[0]["port"];
 						$ip = $home_ip_ports[0]["ip"];
-						$force_mod_id = $home_ip_ports[0]["force_mod_id"];
 						
 						switch ($action) {
 							case "stopServer":