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.
Follow-up to #2407195: Move attachment processing to services and per-type response subclasses
Problem/Motivation
$ajax_page_state = $this->requestStack->getCurrentRequest()->request->get('ajax_page_state');
is wrong.
Proposed resolution
Should be:
$ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
but needs tests coverage.
Remaining tasks
- Fix it
- Write tests
- Commit
User interface changes
- None
API changes
- None
Beta phase evaluation
Issue category | Bug because setting ajax page state via GET is broken. |
---|---|
Issue priority | Major because it renders a turbo links approach that was to be supported useless for no reason. |
Prioritized changes | The main goal of this issue is to fix a bug to allow performance (less data to load) improvements down the road. |
Disruption | Not disruptive at all. |
Comments
Comment #1
Fabianx CreditAttribution: Fabianx for Acquia commentedComment #2
Crell CreditAttribution: Crell at Palantir.net commentedWhere is this alleged code...?
Comment #3
Fabianx CreditAttribution: Fabianx for Acquia commentedCurrently template_preprocess_html() and it looks different:
should be:
What is in the IS is after that other issue is in ...
Comment #4
Wim LeersAll AJAX requests are POST requests. (Yes we are working towards making AJAX GET requests possible too, but we're not there yet.)
Therefore I don't see how we ever can hit this bug. Shouldn't this therefore be normal?
But yes, it is a bug.
Comment #5
Fabianx CreditAttribution: Fabianx for Acquia commentedNope, this is especially there to support rails turbolinks, so for any request to e.g. /node/?ajax_page_state=drupal/drupal
you tell the server, which libraries you have loaded already and it then just loads the remainder, etc.
Comment #6
Wim LeersSure, but in core that never happens.
Comment #7
dawehnerSure, at some point we also want to switch to GET for normal ajax request but still keep support for ajax forms, which will be POST.
Comment #8
melvinlouwerse CreditAttribution: melvinlouwerse as a volunteer and at Ibuildings commentedNot sure if i put the tests in the right directory but as the changed code is in core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php i added it to the directory for Render test. If this is not the correct directory let me know where i should move it to please.
Comment #9
melvinlouwerse CreditAttribution: melvinlouwerse as a volunteer and at Ibuildings commentedComment #12
melvinlouwerse CreditAttribution: melvinlouwerse as a volunteer and at Ibuildings commentedfix the patch
Comment #13
melvinlouwerse CreditAttribution: melvinlouwerse as a volunteer and at Ibuildings commentedComment #14
DuaelFrThank you @melvinlouwerse for this work!
I have two comments, though.
First, I think you should keep using the injected requestStack service (as written in the issue summary) because it makes the method more testable and it also avoids an unneeded call to the container.
Also, could you please also post a test-only patch to be sure that the existing code is failing? See that documentation on how to write tests that includes that part: https://www.drupal.org/contributor-tasks/write-tests
Comment #15
DuaelFrComment #16
Wim Leers@melvinlouwerse Feel free to assign the issue to yourself :)
Comment #17
melvinlouwerse CreditAttribution: melvinlouwerse as a volunteer and at Ibuildings commentedComment #18
melvinlouwerse CreditAttribution: melvinlouwerse as a volunteer and at Ibuildings commentedSorry i indeed seem to have copied the wrong piece of code (from a comment not from the summary).
Comment #19
melvinlouwerse CreditAttribution: melvinlouwerse as a volunteer and at Ibuildings commentedComment #22
Fabianx CreditAttribution: Fabianx for Acquia commentedHah, so great to see an issue get done while away!
Thanks so much @melvinlouwerse
RTBC, nice work on the tests!
--
Added beta evaluation.
Comment #23
legolasboRTBC +1
Comment #25
effulgentsia CreditAttribution: effulgentsia at Acquia commentedYay, nice to see this fixed! Pushed to 8.0.x.
Comment #26
claudiu.cristeaThis is causing errors on the old bot. Followup #2579965: AssertContentTrait "use"d twice in AjaxPageStateTest.