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'));
Comments
Comment #2
sergiu stici commentedComment #3
sergiu stici commentedComment #4
anybodyCleaning up the module versions with Drupal 8 & 9 compatible 3.x release. We have to sort out outdated issues to focus on 3.x stabilization. Older Drupal 8 versions (8.x-2.x and 8.x-1.x) will be deprecated soon, so it doesn't make much sense anymore to fix them. Please instead retest if this issue is still relevant for latest 3.x version. If you should experience other issues, please create a separate issue for that, if not already existing.
If the issue from this request still exists in 3.x, please create a Merge Request (MR) against the latest 3.x-dev version to fix the issue and tell us about the actual problem and expected result.
Thank you very much! Let's get this module fixed together as community :)
Comment #5
siemen_hermans commentedProviding an updated patch for the 4.x-dev version
Comment #6
anybodyComment #7
anybodyComment #8
anybodyCould this please be turned into a MR? @siemen_hermans?
Comment #9
anybodyComment #11
smustgrave commentedWill include in 5.0.x branch.