Problem/Motivation

Updating site with update.php gives offset error. Using latest eu_cookie_compliance Drupal 7.1.37 version and latest Drupal 7.84.

Steps to reproduce

click update.php. Error:

Notice: Undefined offset: 0 in _eu_cookie_compliance_remove_script_from_loader (line 858 from /sites/modules/eu_cookie_compliance/eu_cookie_compliance.module

Proposed resolution

may be something like this for Drupal 8 needs to be downgraded to Drupal 7 version?
https://www.drupal.org/project/eu_cookie_compliance/issues/3152989

Remaining tasks

User interface changes

API changes

Thanks a lot for your reply in advance!
Greetings, Martijn

Data model changes

CommentFileSizeAuthor
#7 eu_cookie_compliance-3256939-7.patch634 bytespoker10

Comments

Summit created an issue. See original summary.

svenryen’s picture

Hi Martijn! Thanks for the report.

Do you keep seeing this notice after the update has completed?
It seems that the function got some unexpected input, but it's not clear from the report what was the input.

summit’s picture

Hi,

I see this after the update in my admin screen. But when I clear caches the notice is gone.
any time I update a module, this notice appears again.

Latest notice:

Notice: Undefined offset: 0 in _eu_cookie_compliance_remove_script_from_loader() (regel 858 van /sites/all/modules/eu_cookie_compliance/eu_cookie_compliance.module).
Notice: Trying to access array offset on value of type null in _eu_cookie_compliance_remove_script_from_loader() (regel 858 van /sites/all/modules/eu_cookie_compliance/eu_cookie_compliance.module).

greetings, Martijn

svenryen’s picture

Thanks, that was helpful information. I'll take a look at this in the weekend.

poker10’s picture

We have experiencing this issue too.

Notice: Undefined offset: 0 in _eu_cookie_compliance_remove_script_from_loader() (riadok 858 from /xxx/sites/all/modules/eu_cookie_compliance/eu_cookie_compliance.module).
Notice: Undefined index: scope v drupal_get_js() (riadok 4472 z /xxx/includes/common.inc).

To workaround this I think that update.php needs to be considered as an admin page by default. So we need to change this to fix the problem:

  if (!empty($popup_settings['exclude_admin_pages']) && path_is_admin($current_path)) {
    $path_is_excluded = TRUE;
  }

To something like this (devel has the same strstr() condition):

  if ((!empty($popup_settings['exclude_admin_pages']) && path_is_admin($current_path)) || strstr($_SERVER['PHP_SELF'], 'update.php')) {
    $path_is_excluded = TRUE;
  }

After this the notices are gone.

summit’s picture

Hi, Could you make a patch of this, as such, with new updates it can be considered?
Thanks!
greetings, Martijn

poker10’s picture

Status: Active » Needs review
StatusFileSize
new634 bytes

Well it seems like that this problems does not only affect update.php, but also other "system" calls like system/ajax and similar, which gives this undefined error. So my propsal to add update.php to that condition was not enough.

We are now using this patch.

The function _eu_cookie_compliance_get_script_key() will return FALSE if the script is not found, but this was not taken into account while calling _eu_cookie_compliance_remove_script_from_loader() function. The patch will ensure that the function will not be called if the script was not found (so no script can be modified anyway).

Can you test this patch if it will work for you?

svenryen’s picture

Status: Needs review » Reviewed & tested by the community

  • svenryen committed f4b7535 on 7.x-1.x authored by poker10
    Issue #3256939 by poker10, Summit, svenryen: Undefined offset...
svenryen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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