I am not sure why no one has ever come accross this...

In AdvAgg.module advagg_build_ajax_js_css() this code is used to retrieve the 'settings':

  if (isset($items['js']['settings'])) {
    $settings = $items['js']['settings'];
    unset($items['js']['settings']);
  }

But $items has already been through (where $type = 'js'):

$items[$type] = array_diff_key($items[$type], $_POST['ajax_page_state'][$type]);

And if $_POST['ajax_page_state'][$type] already contains 'settings' then $items['js']['settings'] will always be empty.

If you take a look at the original implementation in core (ajax_render in ajax.inc) this is what they do:

  // Now add a command to merge changes and additions to Drupal.settings.
  $scripts = drupal_add_js();
  if (!empty($scripts['settings'])) {
    $settings = $scripts['settings'];
    array_unshift($commands, ajax_command_settings(call_user_func_array('array_merge_recursive', $settings['data']), TRUE));
  }

They call again drupal_add_js() because they know that the 'settings' information has already been lost from the $items array during the previous logic.

Advagg should mimic the original implementation to retrieve the settings data:

  $scripts = drupal_add_js();
  if (isset($scripts['settings'])) {
    $settings = $scripts['settings'];
    unset($items['js']['settings']);
  }

Patch comming....

CommentFileSizeAuthor
#3 2499149-settings-lost-ajax.patch795 bytesdavid_garcia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

david_garcia’s picture

Issue summary: View changes
david_garcia’s picture

Issue summary: View changes
david_garcia’s picture

Status: Active » Needs review
FileSize
795 bytes
mikeytown2’s picture

Status: Needs review » Fixed

Guessing I missed this from a core fix that when in. Thanks for your hard work on tracking this bug down and for the patch!

Status: Fixed » Closed (fixed)

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