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.
ajax_render behaves differently in regards to changing settings from hook_js_alter(). It throws away the altered copy and uses an unaltered copy.
Comment | File | Size | Author |
---|---|---|---|
#8 | D7-ajax_render_alter_settings-1448796-8-do-not-test.patch | 1.58 KB | czigor |
#6 | ajax_render_alter_settings-1448796-6.patch | 1.27 KB | balsama |
ajax_render_alter_settings.patch | 1.29 KB | bdragon | |
Comments
Comment #2
ygerasimov CreditAttribution: ygerasimov commentedBug confirmed. Patch solves the issue. Thank you.
Comment #3
kenianbei CreditAttribution: kenianbei commentedSame here, patch fixes issue for me as well.
Comment #4
kenianbei CreditAttribution: kenianbei commentedajax_render_alter_settings.patch queued for re-testing.
Comment #6
balsamaRe-roll attached.
Comment #7
balazswmann CreditAttribution: balazswmann commentedI have attached the Drupal 7 version of the last submitted patch.
Comment #8
czigor CreditAttribution: czigor commentedA reroll of #7.
Comment #9
mgiffordShouldn't this be Needs Work rather than Needs Review?
Comment #12
balsama@mgifford Well, now it does. It passed tests 15 months ago, but obviously needs a re-roll again now. Unfortunately, there's not much motivation to re-roll it again if it's just going to languish for another 15 months :)
Comment #13
mgiffordSome issues get forgotten in the issue queues. Often it just takes a small community of folks to keep nudging it to the top.
Comment #14
mgiffordWell it seems that the function ajax_render() no longer exists. Closest I could find was:
core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php:
$this->moduleHandler->alter('ajax_render', $commands);
or maybe:
core/lib/Drupal/Core/Form/form.api.php:
function hook_ajax_render_alter(array &$data) {
So should we mark this issue as closed?
Comment #23
larowlan@balsama @czigor any chance you could test if this still impacts Drupal 9?
This needs steps to reproduce and and issue summary update
Comment #24
balsamaSorry, but I'm not sure I knew how to reproduce when I originally interacted with this issue - much less now. I can't imagine why I was involved and I don't understand the IS now. :p
Comment #25
mdupontAFAICS, Drupal 9 is not impacted. AjaxResponseAttachmentsProcessor::buildAttachmentsCommands(), which invokes hook_ajax_render_alter(), correctly handles alterations made to DrupalSettings through hook_js_alter() / hook_js_settings_alter().
See also AssetResolver::getJsAssets(), which is called from the function above and handles the Settings alteration.
Comment #26
larowlanSo does that mean this should be moved to D7?
Comment #27
mdupontLet's move it to D7 indeed.
Comment #28
mdupontCannot reproduce it on the latest Drupal 7.x. Here is what I've done:
Result: I can correctly see my "test: 1" setting both in the Ajax HTTP response and in the page when calling
console.log(Drupal.settings);
from the javascript console.I guess we can close this issue as CNR.
Comment #29
larowlanThanks @mdupont