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.

Comments

Ollie222 created an issue. See original summary.

ollie222’s picture

  • svenryen committed fd57edb on 7.x-1.x authored by Ollie222
    Issue #3277679 by Ollie222: Cookie banner fails to popup due to eu_only...
svenryen’s picture

Status: Active » Fixed

Thanks for catching this. Committed to the dev branch.

ollie222’s picture

That was fast work, thanks.

  • svenryen committed fd57edb on 7.x-2.x authored by Ollie222
    Issue #3277679 by Ollie222: Cookie banner fails to popup due to eu_only...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.