From cafbfd7dc03d2289fd0d5d041ba85a3adfdef6b1 Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Wed, 24 Jul 2013 11:38:10 +0000 Subject: [PATCH] 2013-07-24 Juan Manuel Ramon Vigo * include/functions_forecast.php: Avoid timeout in prediction date item report. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8565 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++++ .../include/functions_forecast.php | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 951898b579..3d6a3a8e1c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-07-24 Juan Manuel Ramon Vigo + + * include/functions_forecast.php: Avoid timeout in prediction date + item report. + 2013-07-24 Sergio Martin * include/functions_visual_map.php diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index d6ada986ed..9394526b3d 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -34,6 +34,16 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_period, $max_value = false, $min_value = false, $csv = false){ global $config; + $max_exec_time = ini_get('max_execution_time'); + + if ($max_exec_time !== false) { + + $max_exec_time = (int)$max_exec_time; + + } + + $begin_time = time(); + $module_data=grafico_modulo_sparse ($module_id, $period, 0, 300, 300 , '', null, false, 0, false, @@ -187,6 +197,15 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe $idx = 0; // Create data in graph format like while ($in_range) { + $now = time(); + + // Check that exec time is not greater than half max exec server time + if ($max_exec_time !== false) { + if (($begin_time + ($max_exec_time/2)) < $now) { + return false; + } + } + $timestamp_f = date($time_format, $current_ts); //$timestamp_f = date($time_format, $current_ts);