Skip to content

Commit 6951958

Browse files
fix: ensure a sane default is used for ConfigHistoryRevision's 'filesize' field
1 parent 2b3411d commit 6951958

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/ConfigHistoryRevision.inc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ConfigHistoryRevision extends Model {
3030
help_text: 'The configuration version associated with this change.',
3131
);
3232
$this->filesize = new IntegerField(
33-
default: 0,
33+
default: -1,
3434
help_text: 'The file size (in bytes) of the configuration file associated with this change.',
3535
);
3636

@@ -42,8 +42,18 @@ class ConfigHistoryRevision extends Model {
4242
* @return array The configuration history as an array of objects.
4343
*/
4444
protected function get_config_history(): array {
45+
# Get our current configuration history, but remove the versions key. These are not needed for the Model.
4546
$config_history = get_backups();
4647
unset($config_history['versions']);
48+
49+
# Loop through each entry in the configuration history and normalize the data
50+
foreach ($config_history as &$entry) {
51+
# If filesize is not a numeric, set it to the default
52+
if (!is_numeric($entry['filesize'])) {
53+
$entry['filesize'] = $this->filesize->default;
54+
}
55+
}
56+
4757
return $config_history;
4858
}
4959

0 commit comments

Comments
 (0)