Skip to content

fix #83#101

Merged
alorbach merged 1 commit intorsyslog:masterfrom
Tejas242:dev
Apr 9, 2026
Merged

fix #83#101
alorbach merged 1 commit intorsyslog:masterfrom
Tejas242:dev

Conversation

@Tejas242
Copy link
Copy Markdown
Contributor

This pull request introduces a new configuration setting to control the maximum number of records exported in the src/export.php file. The changes ensure that exports are limited based on this setting, improving performance and preventing excessive data handling.

Configuration Update:

  • src/include/config.sample.php: Added a new configuration setting, ExportMaxRecords, with a default value of 10,000. This setting allows administrators to define the maximum number of records to export, with 0 indicating no limit.

Export Logic Enhancement:

  • src/export.php: Introduced a variable $maxExportRecords to fetch the ExportMaxRecords configuration value. If set to 0, it defaults to PHP_INT_MAX to allow unlimited exports. This ensures flexibility in export limits.
  • src/export.php: Updated the export loop condition to use $maxExportRecords instead of the previous CurrentViewEntriesPerPage, effectively enforcing the export limit.

@alorbach
Copy link
Copy Markdown
Member

alorbach commented Apr 9, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a configurable limit for the number of records exported, adding a new setting 'ExportMaxRecords' to the configuration. The review feedback suggests improving the robustness of the implementation by casting the configuration value to an integer and treating all non-positive values as an 'unlimited' export option, along with updating the configuration documentation to reflect this behavior.

Comment thread src/export.php
Comment on lines +146 to +150
$maxExportRecords = GetConfigSetting("ExportMaxRecords", 10000, CFGLEVEL_GLOBAL);
if ($maxExportRecords == 0) {
// No limit - export all matching records
$maxExportRecords = PHP_INT_MAX;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For better robustness, it's good practice to explicitly cast the configuration value to an integer. Also, handling non-positive values (i.e., <= 0) instead of just == 0 for the unlimited case would prevent unexpected behavior if a user configures a negative number, which would currently result in no records being exported.

		$maxExportRecords = (int) GetConfigSetting("ExportMaxRecords", 10000, CFGLEVEL_GLOBAL);
		if ($maxExportRecords <= 0) {
			// No limit - export all matching records
			$maxExportRecords = PHP_INT_MAX;
		}


// --- Default Export options
$CFG['ExportUseTodayYesterday'] = 0; // Same as ViewUseTodayYesterday. By default export normal dates
$CFG['ExportMaxRecords'] = 10000; // Maximum number of records to export. 0 means no limit (export all matching records)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To align with the improved logic of treating any non-positive value as 'no limit', it would be clearer to update this comment to reflect that both 0 and negative values result in unlimited exports. This helps prevent user confusion during configuration.

$CFG['ExportMaxRecords'] = 10000;                      // Maximum number of records to export. 0 or a negative value means no limit (export all matching records)

@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.

No issues found across 2 files

@alorbach alorbach merged commit 9be3f98 into rsyslog:master Apr 9, 2026
1 check passed
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