From 26f2d819c55560a72faf221d3089b3a1fecc6236 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Sun, 17 May 2026 00:40:14 +0300 Subject: [PATCH 1/4] Avoid endless AJAX table update requests if the query returned 0 rows on the Log page. (log.js) --- web/skins/classic/views/js/log.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/log.js b/web/skins/classic/views/js/log.js index 7f3880ed52d..a9a26389092 100644 --- a/web/skins/classic/views/js/log.js +++ b/web/skins/classic/views/js/log.js @@ -56,7 +56,9 @@ function ajaxRequest(params) { success: function(data) { if (!data.rows.length) { // If page is > 1, bt infinitely loops - table.bootstrapTable('selectPage', 1); + // IgorA100 commented out the code below because it leads to endless table updates if the query returns 0 rows. + // This may have been a hack due to incorrect page pagination, which was fixed in https://github.com/ZoneMinder/zoneminder/pull/4818 + //table.bootstrapTable('selectPage', 1); } // rearrange the result into what bootstrap-table expects params.success({ From dcf03c82e60086b87b82ad6cd1046679f3702325 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Sun, 17 May 2026 19:48:42 +0300 Subject: [PATCH 2/4] More accurate page navigation and statistics display (log.js) --- web/skins/classic/views/js/log.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/views/js/log.js b/web/skins/classic/views/js/log.js index a9a26389092..81b993efa44 100644 --- a/web/skins/classic/views/js/log.js +++ b/web/skins/classic/views/js/log.js @@ -54,11 +54,10 @@ function ajaxRequest(params) { data: params.data, timeout: 0, success: function(data) { - if (!data.rows.length) { - // If page is > 1, bt infinitely loops - // IgorA100 commented out the code below because it leads to endless table updates if the query returns 0 rows. - // This may have been a hack due to incorrect page pagination, which was fixed in https://github.com/ZoneMinder/zoneminder/pull/4818 - //table.bootstrapTable('selectPage', 1); + if (!data.rows.length && data.total > 0) { + // If the page is greater than 1, it loops infinitely. + table.bootstrapTable('selectPage', 1); + return; } // rearrange the result into what bootstrap-table expects params.success({ @@ -95,8 +94,8 @@ function filterLog() { function updateHeaderStats(data) { var pageNum = table.bootstrapTable('getOptions').pageNumber; var pageSize = table.bootstrapTable('getOptions').pageSize; - var startRow = ( (pageNum - 1 ) * pageSize ) + 1; - var stopRow = pageNum * pageSize; + var startRow = (data.total > 0) ? (( (pageNum - 1 ) * pageSize ) + 1) : 0; + var stopRow = (data.total > 0) ? ((data.total > pageSize) ? pageNum * pageSize : data.total) : 0; var newClass = (data.logstate == 'ok') ? 'text-success' : (data.logstate == 'alert' ? 'text-warning' : ((data.logstate == 'alarm' ? 'text-danger' : ''))); $j('#logState').text(data.logstate); From a01f196917f5cec84112297198b2cb28ab230e8d Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Wed, 20 May 2026 20:35:06 +0300 Subject: [PATCH 3/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- web/skins/classic/views/js/log.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/log.js b/web/skins/classic/views/js/log.js index 81b993efa44..585034a71c3 100644 --- a/web/skins/classic/views/js/log.js +++ b/web/skins/classic/views/js/log.js @@ -95,7 +95,7 @@ function updateHeaderStats(data) { var pageNum = table.bootstrapTable('getOptions').pageNumber; var pageSize = table.bootstrapTable('getOptions').pageSize; var startRow = (data.total > 0) ? (( (pageNum - 1 ) * pageSize ) + 1) : 0; - var stopRow = (data.total > 0) ? ((data.total > pageSize) ? pageNum * pageSize : data.total) : 0; + var stopRow = (data.total > 0) ? Math.min(data.total, pageNum * pageSize) : 0; var newClass = (data.logstate == 'ok') ? 'text-success' : (data.logstate == 'alert' ? 'text-warning' : ((data.logstate == 'alarm' ? 'text-danger' : ''))); $j('#logState').text(data.logstate); From 27d196a53be8146fd09a0d4bc3daf8de117e2f55 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Wed, 20 May 2026 20:36:33 +0300 Subject: [PATCH 4/4] Edited comment (log.js) --- web/skins/classic/views/js/log.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/log.js b/web/skins/classic/views/js/log.js index 585034a71c3..b1becec42c2 100644 --- a/web/skins/classic/views/js/log.js +++ b/web/skins/classic/views/js/log.js @@ -55,7 +55,7 @@ function ajaxRequest(params) { timeout: 0, success: function(data) { if (!data.rows.length && data.total > 0) { - // If the page is greater than 1, it loops infinitely. + // The requested page is out of range; reset to page 1. table.bootstrapTable('selectPage', 1); return; }