Hook restrict_ip_whitelisted_js_keys doesn't work correctly

Created on 7 December 2018, about 6 years ago
Updated 22 September 2023, about 1 year ago

In function restrict_ip_js_alter(), the whitelist keys from the hook are added to the default whitelist using the + operator:

$whitelisted_js_keys += Drupal::service('module_handler')->invokeAll('restrict_ip_whitelisted_js_keys');

However this doesn't work as expected because the + operator uses the key from the left side if the two arrays have the same keys . This causes the first three JS keys of your hook to always be ignored. Changing this line to use array_merge() solves the issue:

$whitelisted_js_keys = array_merge($whitelisted_js_keys, Drupal::service('module_handler')->invokeAll('restrict_ip_whitelisted_js_keys'));
🐛 Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

🇳🇱Netherlands jeroen_vreuls

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024