Skip to content

When rendering forms, missing default value can cause errors #5780

@MSS970

Description

@MSS970

CACTI version [1.3.0 - Dev]

The below error occurs when attempting to edit a threshold.

2024-06-26 18:19:34 - PHP ERROR WARNING Backtrace: (D:\cacti\apache\htdocs\cacti\plugins\thold\thold.php[144]:thold_edit(), D:\cacti\apache\htdocs\cacti\plugins\thold\thold.php[2266]:draw_edit_form(), D:\cacti\apache\htdocs\cacti\lib\html_form.php[56]:CactiErrorHandler())

2024-06-26 18:19:34 - ERROR PHP WARNING: Undefined array key "default" in file: D:\cacti\apache\htdocs\cacti\lib\html_form.php on line: 56


Root Cause:
Some hidden config fields do not have array key 'default'
The error occurs at line 56
$field_array['value'] = $field_array['default'];

Solution:
Replace line 56 with:

				//$field_array['value'] = $field_array['default'];
				if (array_key_exists('default', $field_array)) {
					$field_array['value'] = $field_array['default'];
				} else {
					$field_array['value'] = '';
				}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourconfirmedBug is confirm by dev teamresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions