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....
Comment | File | Size | Author |
---|---|---|---|
#3 | 2499149-settings-lost-ajax.patch | 795 bytes | david_garcia |
Comments
Comment #1
david_garcia CreditAttribution: david_garcia commentedComment #2
david_garcia CreditAttribution: david_garcia commentedComment #3
david_garcia CreditAttribution: david_garcia commentedComment #4
mikeytown2 CreditAttribution: mikeytown2 commentedGuessing I missed this from a core fix that when in. Thanks for your hard work on tracking this bug down and for the patch!