Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
$stream = $stream_config->LogStreamFactory($stream_config);
$stream->SetFilter($content['searchstr']);

// --- Set the maximum number of records to export
$maxExportRecords = GetConfigSetting("ExportMaxRecords", 10000, CFGLEVEL_GLOBAL);
if ($maxExportRecords == 0) {
// No limit - export all matching records
$maxExportRecords = PHP_INT_MAX;
}
Comment on lines +146 to +150
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;
		}


// Copy current used columns here!
$content['Columns'] = $content['Views'][$currentViewID]['Columns'];

Expand Down Expand Up @@ -286,7 +293,7 @@

// Increment Counter
$counter++;
} while ($counter < $content['CurrentViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS);
} while ($counter < $maxExportRecords && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS);

if ( $content['read_direction'] == EnumReadDirection::Forward )
{
Expand Down
1 change: 1 addition & 0 deletions src/include/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

// --- 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)


// --- Default Frontend Options
$CFG['PrependTitle'] = ""; // If set, this text will be prepended withint the title tag
Expand Down