The following notice is thrown in my website:

Notice: Undefined index: consent_storage_callback in eu_cookie_compliance_store_consent() (line 858 of /var/www/html/sites/all/modules/contrib/eu_cookie_compliance/eu_cookie_compliance.module).

Also clicking on :

my-website/eu-cookie-compliance/store_consent/banner

The following FATAL ERROR is thrown:

Fatal error: Function name must be a string in /var/www/html/sites/all/modules/contrib/eu_cookie_compliance/eu_cookie_compliance.module on line 859

I'm using last 7.x-1.31+2-dev (2020-Jan-27) DEV version.

Comments

MXT created an issue. See original summary.

svenryen’s picture

Hi!

Thanks for the report. I'll take a look.

It would help speed up the debugging if you could run drush vget eu_cookie_compliance and paste the result here.

mxt’s picture

drush vget eu_cookie_compliance
eu_cookie_compliance: array (
  'popup_enabled' => 1,
  'method' => 'opt_in',
  'info_template' => 'new',
  'cookie_categories' => '',
  'enable_save_preferences_button' => 1,
  'save_preferences_button_label' => 'Save preferences',
  'accept_all_categories_button_label' => 'Accept all cookies',
  'fix_first_cookie_category' => 1,
  'select_all_categories_by_default' => 0,
  'disabled_javascripts' => '',
  'whitelisted_cookies' => '',
  'consent_storage_method' => 'do_not_store',
  'popup_clicking_confirmation' => false,
  'popup_info' => 
  array (
    'value' => '<p><strong>We use cookies (including third-party cookies that perform profiling) on this site to enhance your user experience</strong></p>

<p>By clicking any link on this page you are giving your consent for us to set cookies.</p>
',
    'format' => 'filtered_html',
  ),
  'use_mobile_message' => 0,
  'mobile_popup_info' => 
  array (
    'value' => '',
    'format' => 'forum',
  ),
  'mobile_breakpoint' => '768',
  'popup_agree_button_message' => 'OK, I agree',
  'show_disagree_button' => true,
  'popup_disagree_button_message' => 'No, give me more info',
  'disagree_button_label' => 'Decline',
  'withdraw_enabled' => 0,
  'withdraw_button_on_info_popup' => 0,
  'withdraw_message' => 
  array (
    'value' => '',
    'format' => 'forum',
  ),
  'withdraw_tab_button_label' => '',
  'withdraw_action_button_label' => '',
  'popup_agreed_enabled' => 0,
  'popup_hide_agreed' => 0,
  'popup_agreed' => 
  array (
    'value' => '<h2>Thank you for accepting cookies</h2>

<p>You can now hide this message or find out more about cookies.</p>
',
    'format' => 'full_html',
  ),
  'popup_find_more_button_message' => 'More info',
  'popup_hide_button_message' => 'Hide',
  'popup_link' => 'http://www.my-website.com/en/legal#anchor-cookies',
  'popup_link_new_window' => 0,
  'popup_position' => false,
  'use_bare_css' => 0,
  'popup_text_hex' => 'ffffff',
  'popup_bg_hex' => '0779BF',
  'popup_height' => '',
  'popup_width' => '100%',
  'fixed_top_position' => 0,
  'popup_delay' => '1000',
  'disagree_do_not_show_popup' => 0,
  'reload_page' => 0,
  'popup_scrolling_confirmation' => false,
  'cookie_name' => '',
  'domains_option' => '1',
  'domains_list' => '',
  'exclude_paths' => '',
  'exclude_admin_pages' => 0,
  'exclude_uid_1' => 0,
  'script_scope' => 'footer',
  'better_support_for_screen_readers' => 0,
  'cookie_session' => 0,
)
eu_cookie_compliance_cookie_lifetime: '100'
eu_cookie_compliance_domain: ''
eu_cookie_compliance_domain_all_sites: 0
svenryen’s picture

Thanks. I'll take a look.

svenryen’s picture

Do you by any chance have a multilingual web site? I can't reproduce directly.

svenryen’s picture

Status: Active » Postponed (maintainer needs more info)
goekmen’s picture

I also have this problem

Notice: Undefined index: consent_storage_callback in eu_cookie_compliance_store_consent() (Zeile 858 von /****/modules/eu_cookie_compliance/eu_cookie_compliance.module).
I am runnig a multilingual website.

mxt’s picture

Yes I have a multilingual website.

danjuls’s picture

Same here, multilingual site and the same notice.

anybody’s picture

Status: Postponed (maintainer needs more info) » Active

Ok let's have a look...

  // Get plugin.
  $consent_storage_plugin = ctools_get_plugins('eu_cookie_compliance', 'consent_storage', $consent_storage_method);
  $consent_storage_function = $consent_storage_plugin['consent_storage_callback'];
  $result = $consent_storage_function($type);

ctools_get_plugins('eu_cookie_compliance', 'consent_storage', $consent_storage_method);

doesn't return a proper value (method name). The reason might be outside, for example it would be interesting to hear which ctools versions the users are using here and what's returned instead.

Anyway I'd suggest to check by function_exists($consent_storage_function) that the given function exists and log error details if not. Furthermore I'm a bit afraid if it's secure to call a function returned by variable without limitations and prior checks?

fgiacanelli’s picture

Hello,

just a quick note:

it happened to one of our sites when upgrading from the version 7.x-1.31 of the module to the 1.32.

The prior istallation didn't have the consent_storage_method variable thus it was set to null.

The 1.32 configuration screen offers the choice with a radio button:
- Do not store (selected by default)
- basic storage

It appears that if the user doesn't intentionally save the configuration for *every* language of a multi language site, the variable is null so throwing the error when a user clicks on accept on the banner.

Note: I didn't inspect the code, I just reproduced the error. I set the variable first on a single language: no more errors in the log for users landing on that language, more errors for users landing on the other language (you can check this by manually going on the home page of a language on a new incognito/anonyous browser window). When I saved the the configuration on the second language, all errors disappeared.

Workaround: re-save the configuration after every upgrade for every language installed.

svenryen’s picture

Assigned: Unassigned » svenryen
svenryen’s picture

Here's a patch that should resolve the issue.

Test notes:
- Install the module first and then set up a Drupal 7 site with several languages.
- Do *not* save the configuration for the other language, leaving the variable for Consent Storage Method unconfigured.
- Visit the site on the other language and verify that the error doesn't happen.

svenryen’s picture

Assigned: svenryen » neslee canil pinto
Status: Active » Needs review

neslee canil pinto’s picture

Status: Needs review » Fixed

Committed to 7.x dev branch. Thank you.

neslee canil pinto’s picture

Assigned: neslee canil pinto » Unassigned

Status: Fixed » Closed (fixed)

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