Using Drupal 7 and the latest dev version of this module the cookie banner fails to popup.
The config of the setup is to show a banner but without geoip or smart_ip installed.
The error looks to be caused by a javascript error that occurs in eu_cookie_compliance.js on line 31 when it tries to getJSON without a valid url.
if (Drupal.settings.eu_cookie_compliance.popup_eu_only_js) {
if (Drupal.eu_cookie_compliance.showBanner()) {
var url = Drupal.settings.basePath + Drupal.settings.pathPrefix + 'eu-cookie-compliance-check';
var data = {};
$.getJSON(url, data, function (data) {Drupal.settings.eu_cookie_compliance.popup_eu_only_js is set to a string "0" and therefore js evaluates this to true whereas I think it should be set to an integer.
Amongst other things the change 43c1ca630edb86cca33dbcae2d5be88123c5ab26 implemented in this issue https://www.drupal.org/project/eu_cookie_compliance/issues/3261155 adds the code
$form_state['values']['eu_cookie_compliance']['eu_only_js'] = '0';
$form_state['values']['eu_cookie_compliance']['eu_only'] = '0';
if (!empty($form_state['values']['eu_cookie_compliance']['eu_option'])) {
if ($form_state['values']['eu_cookie_compliance']['eu_option'] === 'eu_only') {
$form_state['values']['eu_cookie_compliance']['eu_only'] = '1';
}
elseif ($form_state['values']['eu_cookie_compliance']['eu_option'] === 'eu_only_js') {
$form_state['values']['eu_cookie_compliance']['eu_only_js'] = '1';
}
}
I think these 0 and 1 strings should be integers.
Changing them seems to fix the fault and from my brief testing doesn't seem to cause any other problems.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3277679_eu_only_string_instead_of_int.patch | 1.2 KB | ollie222 |
Comments
Comment #2
ollie222 commentedComment #4
svenryen commentedThanks for catching this. Committed to the dev branch.
Comment #5
ollie222 commentedThat was fast work, thanks.