From f7a99a11062b9eb992887d02f351662eb8a90745 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 13 Jul 2017 11:06:08 -0400 Subject: [PATCH] make montagereview not load all events and frames at once, so that it doesn't use up all memory --- web/skins/classic/views/js/montagereview.js.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/web/skins/classic/views/js/montagereview.js.php b/web/skins/classic/views/js/montagereview.js.php index 512c670d3..0bd0bacde 100644 --- a/web/skins/classic/views/js/montagereview.js.php +++ b/web/skins/classic/views/js/montagereview.js.php @@ -32,7 +32,14 @@ $maxTimeSecs = strtotime('1950-01-01 01:01:01'); $index=0; $anyAlarms=false; -foreach( dbFetchAll( $eventsSql ) as $event ) { +$result = dbQuery( $eventsSql ); +if ( ! $result ) { + Fatal( "SQL-ERR"); + return; +} + +while( $event = $result->fetch( PDO::FETCH_ASSOC ) ) { + if ( $minTimeSecs > $event['StartTimeSecs'] ) $minTimeSecs = $event['StartTimeSecs']; if ( $maxTimeSecs < $event['CalcEndTimeSecs'] ) $maxTimeSecs = $event['CalcEndTimeSecs']; echo " @@ -84,8 +91,9 @@ $fromSecs=-1; $toSecs=-1; $maxScore=-1; -if ( $anyAlarms ) { - foreach( dbFetchAll ($frameSql) as $frame ) { +if ( $anyAlarms && $result = dbQuery( $frameSql ) ) { + + while( $frame = $result->fetch( PDO::FETCH_ASSOC ) ) { if ( $mId < 0 ) { $mId = $frame['MonitorId']; $fromSecs = $frame['TimeStampSecs'];