- Issue created by @whereiam
- Merge request !17fix: undefined array key 'back_to_top_speed' by ensuring a default value → (Open) created by whereiam
When using the Back To Top module, the following warning appears:
Warning: Undefined array key "back_to_top_speed" in back_to_top_page_attachments() (line 35 of modules/contrib/back_to_top/back_to_top.module).
The warning occurs when the back_to_top_speed value is not set in the module's settings.
To prevent the warning, the value of back_to_top_speed should be checked before assigning it.
Replace:
$attachments['#attached']['drupalSettings']['back_to_top']['back_to_top_speed'] = $settings['back_to_top_speed'];
With:
$attachments['#attached']['drupalSettings']['back_to_top']['back_to_top_speed'] = isset($settings['back_to_top_speed']) ? $settings['back_to_top_speed'] : 1000;
This ensures that a default value (1000) is used if back_to_top_speed is not set.
Apply the proposed fix to the codebase.
Test the module after the fix to confirm that the warning no longer appears.
Active
3.0
Code