Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.6k stars 397 forks source link

ERROR PHP WARNING: Undefined array key "default" in file: D:\cacti\apache\htdocs\cacti\lib\html_form.php on line: 56 #5780

Closed MSS970 closed 2 days ago

MSS970 commented 5 days ago

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'] = '';
                }
TheWitness commented 2 days ago

Resolved now. Thanks for your contribution!