Issue #3586658: Threshold type Ajax dropdown fails to refresh fields on response_time sensor form
Closes #3586658.
Fixes the Ajax rebuild of the response time sensor edit form. Changing the Threshold type dropdown (or any other Ajax-triggering select on the sensor form) was silently failing with a PHP 8 TypeError in implode(), leaving the thresholds wrapper un-replaced.
Root cause
ResponseTimeSensorPlugin::buildConfigurationForm() assumed excluded_paths was always an array. On an Ajax rebuild EntityForm::copyFormValuesToEntity() has already written the raw textarea string onto $entity->settings['excluded_paths']; the plugin's submitConfigurationForm() would normalize that string back to an array, but submit handlers don't run on rebuilds. So the next buildConfigurationForm() call saw a string and blew up:
TypeError: implode(): Argument #2 ($array) must be of type ?array, string given
in ResponseTimeSensorPlugin.php:79Fix
Normalize the textarea value to an array during form validation via #element_validate, so the value lives as an array in form state and is copied back onto the entity as an array. The stored type is now invariant across rebuilds.
- Added
splitExcludedPaths()as an#element_validatecallback — splits on newlines, trims, filters empty entries, writes back to form state. - Simplified the
#default_valuecomputation with a defensiveis_array()fallback so configs mis-saved as strings by the previous buggy code path still load. - Removed the now-redundant splitting code from
submitConfigurationForm(); the submit handler override disappears entirely since the parent'ssubmitConfigurationForm()does nothing.
Backwards compatibility
No config schema or API change. excluded_paths remains a sequence of strings.
Manual test
- Edit the
response_timesensor. - Type a path into Paths to exclude (e.g.
/admin/foo/*). - Change the Threshold type dropdown (Exceeds → Falls). Before this MR: watchdog TypeError, threshold fields don't refresh. After: threshold fields refresh normally, sensor saves correctly.