Skip to content

Export all pages, simplified datefrom, and suppress fix#92

Open
rusak47 wants to merge 2 commits intorsyslog:masterfrom
rusak47:mybranch
Open

Export all pages, simplified datefrom, and suppress fix#92
rusak47 wants to merge 2 commits intorsyslog:masterfrom
rusak47:mybranch

Conversation

@rusak47
Copy link
Copy Markdown
Contributor

@rusak47 rusak47 commented Feb 12, 2023

  • export: append exported range timestamp to filename
  • filter: dateto/datefrom add support for offset from current date, i.e. datefrom:T00:00:00 dateto:T01:00:00, datefrom:\-2T, datefrom:\-1T01
  • fixed BUG: "Suppress duplicated messages" + add property to control distance between duplicates
  • GUI: if suppress is enabled, then show how much records were suppressed (LN_GEN_SUPPRESSEDRECORDCOUNT)
  • $CFG[ExportSuppressDuplicatedMessages] - separate export suppressing from view
  • $CFG[ExportAllMatchPages] - allow to control how much to export by default
  • $CFG[DuplicateRecordMaxTsDistance] - check duplicates timestamp before suppressing, i.e. same message with 24h period may not be assumed as duplicate

@rusak47
Copy link
Copy Markdown
Contributor Author

rusak47 commented Feb 26, 2023

@alorbach please, check this pull request.

@alorbach
Copy link
Copy Markdown
Member

alorbach commented Apr 9, 2026

@cubic-dev-ai review

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai bot commented Apr 9, 2026

@cubic-dev-ai review

@alorbach I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/index.php">

<violation number="1" location="src/index.php:357">
P2: Duplicate suppression reads `timereported` without checking presence/shape, which can cause undefined index/offset and incorrect suppression behavior for views/sources lacking that field.</violation>

<violation number="2" location="src/index.php:373">
P2: Suppressed duplicate count is dropped when duplicate runs end at page/stream boundary because pending count is never flushed before loop exit.</violation>

<violation number="3" location="src/index.php:377">
P2: Suppression threshold is off by one: a single suppressed duplicate (`$duplicateCount == 1`) is not reported or counted.</violation>
</file>

<file name="src/export.php">

<violation number="1" location="src/export.php:79">
P2: Export logic uses `SuppressDuplicatedMessages` instead of the new export-specific `ExportSuppressDuplicatedMessages`, so export suppression is still incorrectly coupled to view settings.</violation>

<violation number="2" location="src/export.php:220">
P2: Export now assumes `timereported` is always present, but stream is opened with view columns only, causing possible undefined-index access and broken duplicate/date-range behavior when that field is not selected.</violation>

<violation number="3" location="src/export.php:222">
P2: Duplicate suppression reads `$szLastMessage` before initialization, risking undefined-variable behavior and incorrect first-record suppression.</violation>

<violation number="4" location="src/export.php:334">
P2: Trailing suppressed-duplicate groups are dropped when the stream ends before a non-duplicate triggers summary injection.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread src/index.php
}else{
//inject entry about suppressed records
// FIXME any better way of doing that?
if($duplicateCount > 1){
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Suppression threshold is off by one: a single suppressed duplicate ($duplicateCount == 1) is not reported or counted.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index.php, line 377:

<comment>Suppression threshold is off by one: a single suppressed duplicate (`$duplicateCount == 1`) is not reported or counted.</comment>

<file context>
@@ -336,38 +339,78 @@
+					}else{
+						//inject entry about suppressed records
+						// FIXME any better way of doing that?
+						if($duplicateCount > 1){
+							foreach($content['Columns'] as $mycolkey)
 							{
</file context>
Suggested change
if($duplicateCount > 1){
if($duplicateCount > 0){
Fix with Cubic

Comment thread src/index.php
else
// Skip if same msg
// but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages)
$tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]); //sign depends on direction
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Duplicate suppression reads timereported without checking presence/shape, which can cause undefined index/offset and incorrect suppression behavior for views/sources lacking that field.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index.php, line 357:

<comment>Duplicate suppression reads `timereported` without checking presence/shape, which can cause undefined index/offset and incorrect suppression behavior for views/sources lacking that field.</comment>

<file context>
@@ -336,38 +339,78 @@
-					else
+					// Skip if same msg
+					// but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages)
+					$tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]); //sign depends on direction
+					//echo "uID=$uID; duplicates ($duplicateCount); delta ts = $tsDiff; isDublicate=".($szLastMessage == $logArray[SYSLOG_MESSAGE])."<br>";
+					if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] && ($tsDiff < $DuplicateRecordMaxTsDistance))
</file context>
Fix with Cubic

Comment thread src/index.php
// ---

// Skip entry
continue;
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Suppressed duplicate count is dropped when duplicate runs end at page/stream boundary because pending count is never flushed before loop exit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index.php, line 373:

<comment>Suppressed duplicate count is dropped when duplicate runs end at page/stream boundary because pending count is never flushed before loop exit.</comment>

<file context>
@@ -336,38 +339,78 @@
+						// --- 
+							
+						// Skip entry
+						continue;
+					}else{
+						//inject entry about suppressed records
</file context>
Fix with Cubic

Comment thread src/export.php
if(!$content['ExportAllMatchPages'] && $counter >= $content['CurrentViewEntriesPerPage']){
break;
}
} while ($ret == SUCCESS);
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Trailing suppressed-duplicate groups are dropped when the stream ends before a non-duplicate triggers summary injection.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/export.php, line 334:

<comment>Trailing suppressed-duplicate groups are dropped when the stream ends before a non-duplicate triggers summary injection.</comment>

<file context>
@@ -286,7 +321,17 @@
+					if(!$content['ExportAllMatchPages'] && $counter >= $content['CurrentViewEntriesPerPage']){
+						break;
+					}
+				} while ($ret == SUCCESS);
 
 				if ( $content['read_direction'] == EnumReadDirection::Forward )
</file context>
Fix with Cubic

Comment thread src/export.php
// but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages)
$tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]);
//echo "uID=$uID; duplicates ($duplicateCount); delta ts = $tsDiff; isDublicate=".($szLastMessage == $logArray[SYSLOG_MESSAGE])."<br>\n";
if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] && ($tsDiff < $DuplicateRecordMaxTsDistance))
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Duplicate suppression reads $szLastMessage before initialization, risking undefined-variable behavior and incorrect first-record suppression.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/export.php, line 222:

<comment>Duplicate suppression reads `$szLastMessage` before initialization, risking undefined-variable behavior and incorrect first-record suppression.</comment>

<file context>
@@ -203,32 +205,65 @@
+						// but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages)
+						$tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]);
+						//echo "uID=$uID; duplicates ($duplicateCount); delta ts = $tsDiff; isDublicate=".($szLastMessage == $logArray[SYSLOG_MESSAGE])."<br>\n";
+						if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] && ($tsDiff < $DuplicateRecordMaxTsDistance))
 						{
-							// Skip if same msg
</file context>
Fix with Cubic

Comment thread src/export.php
$content['error_occured'] = false;

$content['ExportAllMatchPages'] = GetConfigSetting("ExportAllMatchPages", 0, CFGLEVEL_USER) == 1;
$content['SuppressDuplicatedMessages'] = GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1;
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Export logic uses SuppressDuplicatedMessages instead of the new export-specific ExportSuppressDuplicatedMessages, so export suppression is still incorrectly coupled to view settings.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/export.php, line 79:

<comment>Export logic uses `SuppressDuplicatedMessages` instead of the new export-specific `ExportSuppressDuplicatedMessages`, so export suppression is still incorrectly coupled to view settings.</comment>

<file context>
@@ -75,6 +75,8 @@
 $content['error_occured'] = false;
 
+$content['ExportAllMatchPages'] 		= GetConfigSetting("ExportAllMatchPages", 0, CFGLEVEL_USER) == 1;
+$content['SuppressDuplicatedMessages'] 	= GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1;
 // Check required input parameters
 if (
</file context>
Suggested change
$content['SuppressDuplicatedMessages'] = GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1;
$content['SuppressDuplicatedMessages'] = GetConfigSetting("ExportSuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1;
Fix with Cubic

Comment thread src/export.php
else
// Skip if same msg
// but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages)
$tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]);
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Export now assumes timereported is always present, but stream is opened with view columns only, causing possible undefined-index access and broken duplicate/date-range behavior when that field is not selected.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/export.php, line 220:

<comment>Export now assumes `timereported` is always present, but stream is opened with view columns only, causing possible undefined-index access and broken duplicate/date-range behavior when that field is not selected.</comment>

<file context>
@@ -203,32 +205,65 @@
-						else
+						// Skip if same msg
+						// but don't merge same messages if timestamp difference is greater than precofigured (useful when filtering same messages)
+						$tsDiff = abs($szLastMessageTimestamp - $logArray["timereported"][EVTIME_TIMESTAMP]);
+						//echo "uID=$uID; duplicates ($duplicateCount); delta ts = $tsDiff; isDublicate=".($szLastMessage == $logArray[SYSLOG_MESSAGE])."<br>\n";
+						if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] && ($tsDiff < $DuplicateRecordMaxTsDistance))
</file context>
Fix with Cubic

@alorbach
Copy link
Copy Markdown
Member

alorbach commented Apr 9, 2026

@rusak47 sorry for the long delay - finally reviewing all PRs here.
If you still interested would be great if you could rebase and look into the findings from cubic, thanks.

@rusak47
Copy link
Copy Markdown
Contributor Author

rusak47 commented Apr 10, 2026

@rusak47 sorry for the long delay - finally reviewing all PRs here. If you still interested would be great if you could rebase and look into the findings from cubic, thanks.

No problem at all — I'm glad it's being reviewed. I believe it could still be useful, but I'll need some time to get back into it, as I haven't used this tool for a while.

Thanks for the heads-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants