Problem/Motivation
When a view with an exposed form (or another form using GET as #method) is being rendered using a lazy builder and that form throws a EnforcedResponseException (for example when the exposed form reset button is pressed), big pipe does not handle this exception; the redirect will not happen.
Steps to reproduce
Using Views Reference Field and a view with exposed filters and ajax:
- Enable Views
- Install module BEF
- Create a view with some exposed filters, enable ajax, enable BEF and activate showing the Reset button.
- Install module Views Reference Field (> 8.x-2.0-beta4)
- Create a content type with a field View Reference and configure it to allow selecting the view created.
- Add a node and select the view
- View the page and use some exposed filters, then when the reset button appears, press it
It will reload the page showing an error instead of the view.
Proposed resolution
Have Big Pipe catch the EnforcedResponseException and send a redirect response ajax command.
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
Big Pipe now handles redirect responses in GET requests.
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | 3304746-nr-bot.txt | 90 bytes | needs-review-queue-bot |
| #31 | 3304746-31.patch | 14.06 KB | casey |
Issue fork drupal-3304746
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
casey commentedSomething like this might do the trick.
Comment #3
casey commentedOops, wrong patch
Comment #4
wim leersWoah! What an edge case you found! 🤯
Comment #5
joseph.olstadComment #6
smustgrave commentedFor the tests in #4
Also the issue summary should be updated to include proposed solution
Comment #8
scott_euser commentedWe have noticed this issue is reproduce-able with the following setup:
Views reference to eg let someone add a View Block to a node (BigPipe
Views ajax history in place to make Views use 'GET'
Better exposed filters enable Reset button
Attempt to click the Reset button, and failure occurs
Hoping to investigate and reproduce this well enough without a series of contrib modules, but for now hopefully this is at least somewhat helpful for others.
The issue only occurs from Views Reference > beta4 as noted here https://www.drupal.org/project/viewsreference/issues/3380691
Comment #9
efrainhHi, I confirm this issue is happening when using Better exposed filters with the reset button + Views Reference Field 8.x-2.0-beta6.
I tested the patch #3 and it kind of worked, but now when we press the Reset button, it redirects first to a URL with a query string and then to the page without the query string, so it reloads twice.
Comment #11
wim leers@scott_euser Thank you! That's very helpful! Any chance you could write a test that reproduces this? 🙏
@efrainh Thank you! It's also very helpful to know that the patch in #3 is an incomplete fix.
Comment #14
scott_euser commentedComment #15
scott_euser commentedOkay I need to work on reproducing this without Views Reference Field module, a bit down my queue though unfortunately.
On the plus side, have managed to get a lot more test coverage into Views Reference Field module itself on (I assume everyone here is here because of some combination of that module and/or Views Ajax History) so hopefully welcome news!
Comment #16
scott_euser commentedSome progress adding a test, need to wait for ajax request, but out of time for today. Hopefully at least it gets someone going further on this (or hopefully I can come back to it soon enough)
Comment #17
scott_euser commentedReady for review
Comment #18
smustgrave commentedRan the test-only feature
Which shows the test coverage, yay!
Issue summary appears complete and proposal to use a catch makes sense. Personally also like the use case added to the comment which really shows what this is getting.
I believe this one should be good.
Comment #19
catchComment #20
scott_euser commentedI guess you mean the ::checkRedirectUrl(), I guess we could:
So some sort of ::getSafeResponse() method somewhere and then ::checkRedirectUrl() becomes something like this semi-pseudo code?
In which case then bigpipe file here can also call ::getSafeResponse.
Some other refactoring in the subscriber needed as well to make that happen, particularly if we move it elsewhere.
Comment #21
scott_euser commentedIf splitting it into a separate (existing??) service, should it be a separate child issue to this one, or okay to be in here?
Comment #22
scott_euser commentedOkay I left out the destination bit, was not sure whether that should be taken across too from RedirectResponseSubscriber::checkRedirectUrl() as it felt a bit like an additional feature and I could not quite think of a use case, but maybe I am wrong.
I added test coverage for the new untrusted response expectation as well.
Should I also be redirecting the untrusted response e.g. to the 403 route, or is just sending the MessageCommand okay? For now its just sending the message as I could not do a fully like for like reproduction of the RedirectResponseSubscriber::checkRedirectUrl(); specifically the 400 status.
In any case, I think it covers the feedback relatively closely (with the notes above) so hopefully we are there or at least close to there with it.
Thanks!
Comment #23
smustgrave commentedBelieve feedback has been addressed
Comment #24
catchCommitted/pushed to 11.x and cherry-picked to 11.0.x, thanks!
This doesn't cherry-pick cleanly to 10.4.x so moving there for backport.
Comment #30
andypostI did re-roll but it adding new properties to constructor so deprecation-mamba and change record are require improvement
Comment #31
casey commentedSnapshot of latest state of MR for usage with composer-patches and D10.3.
Comment #32
andypostrebased and now looks ready
Comment #33
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #34
nod_Comment #35
smustgrave commentedShouldn't we get into 10.5.x too?
We got into 11.0, 11.1, current MR for 10.4.
Comment #37
andypostPatches for 10.5 and 10.4 are the same but I've created new MR
This is a hard blocker for PHP 8.4
Comment #38
smustgrave commentedRe-roll seems good!
Comment #39
alexpottWe're running PHP 8.4 testing on Drupal 10 so not sure how this is a hard blocker?
Comment #40
andypostLooks like it's not a blocker anymore, not clear why but that's great!
Comment #41
joseph.olstadComment #42
scott_euser commentedMaybe fixed instead since it was committed to 11.x?
Comment #43
andypost