Currently the caching of inline js like following:

drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');

drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);

leads to notices like this:
Warning: Invalid argument supplied for foreach() in drupal_array_merge_deep_array() (Line 2045 of drupal/includes/bootstrap.inc).

Inline JS is added to the js array using numeric indexes starting at 0.
Unfortunately the condition if ($key != 'settings') { in panels_cache_object::restore() interprets 0 as 'setting'.
Changing the code to if ($key !== 'settings') { fixes that.

Comments

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Some code which works on views

if (!empty($this->storage['js'])) {
      foreach ($this->storage['js'] as $key => $args) {
        if ($key != 'settings') {
          drupal_add_js($args['data'], $args);
        }
        else {
          foreach ($args as $setting) {
            drupal_add_js($setting, 'setting');
          }
        }
      }
    }
  }
merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed based on on dereine's RTBC.

Status: Fixed » Closed (fixed)

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

  • Commit f48a99e on 7.x-3.x, 7.x-3.x-i18n, 8.x-3.x by merlinofchaos:
    Issue #1463782 by das-peter: Fix caching of inline js