Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Looks like the module intentionally deletes any commands from AJAX rendering that are settings to be merged.
From advagg_ajax_render_alter:
http://cgit.drupalcode.org/advagg/tree/advagg.module#n567
if ( $values['command'] === 'settings'
&& is_array($values['settings'])
&& !empty($values['merge'])
) {
// Remove JS settings.
unset($commands[$key]);
continue;
}
I'm not sure that this is a bug report or a support request, but what is the recommended approach for other code to add settings into a response to be merged with existing settings? Is there perhaps another way around the problem that this code was trying to solve? Happy to chip in with patches if I have a better understanding of the intention.
Comment | File | Size | Author |
---|---|---|---|
#6 | advagg-2349101-5-run-advagg_ajax_render_alter-first.patch | 721 bytes | mikeytown2 |
Comments
Comment #1
eshta CreditAttribution: eshta commentedComment #2
mikeytown2 CreditAttribution: mikeytown2 commentedIt is by design. When does your commands for settings get added? Does is also happen inside of hook_ajax_render_alter when ajax_render is ran? If so then the best option is to have AdvAgg run first for that hook. AdvAgg is a heavy user of hook_module_implements_alter() because the ordering of hooks is vital in a lot of places.
Comment #3
eshta CreditAttribution: eshta commentedOur settings are added via ajax_command_settings and returned from an AJAX callback using ajax_render.
Comment #4
mikeytown2 CreditAttribution: mikeytown2 commentedAdvAgg also uses ajax_command_settings http://cgit.drupalcode.org/advagg/tree/advagg.module#n594. ajax_command_settings is a way to merge in the commands from $settings['data']; those commands get added to the $commands array either from $settings['data'] via drupal_add_js or hook_ajax_render_alter from what I can tell.
AdvAgg replays the same code that core runs because core doesn't expect something like AdvAgg where it overrides aggregation. I'll go ahead and change advagg hook execution order so advagg_ajax_render_alter runs first.
Comment #6
mikeytown2 CreditAttribution: mikeytown2 commentedThis patch has been committed. You'll need to flush drupal's caches in order for it to take effect as hook_module_implements_alter is cached.
Let me know if how this goes.
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commented