Problem/Motivation
If you submit the admin/modules form in the overlay, the form submits, but a second reload appears to close the overlay, which also removes any drupal_set_message()s which were shown (for a fraction of a second) in the overlay before it closed.
Steps to reproduce:
- Install a fresh D8
- Go to example.com/#overlay=admin/modules https://skitch.com/alanevans/ewcx2/extend-testd8cache.localhost
- Choose a random module and check its box https://skitch.com/alanevans/ewct8/extend-testd8cache.localhost
- Submit the form https://skitch.com/alanevans/ewctj/extend-testd8cache.localhost
Expected result:
Forms submits and overlay remains open; Any message confirming module enabling is displayed in the overlay.
Actual result:
The overlay including messages appears for a fraction of a second to load, then the modules form reloads in the parent page, thereby closing the overlay. https://skitch.com/alanevans/ewctw/extend-testd8cache.localhost
Additional observations:
- The POST request triggered by submitting the form returns an explicit redirect to the non-overlay url. On my test site, the target of the POST request is http://testd8cache.localhost:8083/admin/modules/list/confirm?render=overlay and the url from the Location: header is http://testd8cache.localhost:8083/admin/modules
- The issue appears to be caused by a drupal_static_reset in drupal_flush_all_caches called when any module is enabled or disabled. The reasoning behind flushing all caches including static on module enable is sound, but has the effect of killing statically cached data in, say, the overlay (and probably some other areas that rely on it).
I believe this is major in that it is a regression from previously working behaviour, but can also see a case for it being downgraded to "normal" given the relatively low impact (it doesn't seem to be destructive to form data).
Proposed resolution
A couple of options:
- don't use drupal_static for the overlay
- add logic to drupal_static which allows for certain items to be protected from general wipes like this
Remaining tasks
- Pick a resolution
- Patch
- Test + Review
- Is it testable?
Comment | File | Size | Author |
---|---|---|---|
#29 | 1788888-test-screenshot.png | 477.72 KB | sjbassett |
#16 | overlaymoduleafter1.png | 49.57 KB | andymartha |
#14 | overlay-modules-form-submit-1788888-14-WITH-TESTS.patch | 2.83 KB | David_Rothstein |
#14 | overlay-modules-form-submit-1788888-14.patch | 742 bytes | David_Rothstein |
#9 | overlay-prevent-loss-on-modules-form-submit-1788888-9.patch | 738 bytes | jsacksick |
Comments
Comment #0.0
Alan Evans CreditAttribution: Alan Evans commentedUpdated issue summary.
Comment #1
Alan Evans CreditAttribution: Alan Evans commentedappears that overlay_drupal_goto_alter has lost the overlay status of the form - up until that point, the overlay mode is "child", but in that function, it is empty.
Comment #2
Alan Evans CreditAttribution: Alan Evans commentedGetting lost somewhere between drupal_process_form and drupal_redirect_form on the form submit.
Comment #3
Alan Evans CreditAttribution: Alan Evans commentedoverlay_get_mode()'s value of "child" gets lost durin form_execute_handlers('submit' ...), shouldn't be too hard to work out where.
Comment #4
Alan Evans CreditAttribution: Alan Evans commentedoverlay_get_mode()'s value of "child" gets lost durin form_execute_handlers('submit' ...), shouldn't be too hard to work out where.
Comment #5
Alan Evans CreditAttribution: Alan Evans commentedOn module enable, a drupal_flush_all_caches() is run, which includes these lines:
That's what kills the overlay's status.
I imagine this has other side effects.
Comment #6
Alan Evans CreditAttribution: Alan Evans commentedAppears to have been introduced by the patch committed for #1404198: Separate database cache clearing from static cache clearing and data structure rebuilding
Comment #6.0
Alan Evans CreditAttribution: Alan Evans commentedAdditional notes on the request flow
Comment #7
Alan Evans CreditAttribution: Alan Evans commentedThe reasoning behind the patch for 1404198 seems sound, so I think we'd need to find a new solution for the overlay.
Comment #8
tim.plunkettDoes this need backport to D7?
Comment #9
jsacksick CreditAttribution: jsacksick commentedHere's a patch that uses static instead of drupal_static.
Comment #10
hass CreditAttribution: hass commented#1116326: Support admin overlay in exposed forms may be a duplicate, but code has lot of differences.
Comment #11
hass CreditAttribution: hass commentedComment #12
David_Rothstein CreditAttribution: David_Rothstein commentedNote the patch at #1848210: [Tests] Submitting a form in Overlay shows content + dsm() for a split second before redirecting to front-end theme is about a slightly different issue, but also contains the same code change here (it is fixing both bugs at once at the moment, because they're visually similar).
The change probably makes sense but I'll mention here a couple concerns I brought up there:
These might be good candidates for followup issues, though.
Comment #13
David_Rothstein CreditAttribution: David_Rothstein commentedAlso, this bug doesn't occur in Drupal 7.
I'm not removing the "needs backport to D7" tag just yet, though, because there might be an argument for making the same code change in Drupal 7 anyway... I'm not sure.
Comment #14
David_Rothstein CreditAttribution: David_Rothstein commentedI tried to write tests for this issue (along the same lines as the tests that were added in #1848210: [Tests] Submitting a form in Overlay shows content + dsm() for a split second before redirecting to front-end theme) but it didn't work because the modules page explicitly sets $form['#action'] to a specifc URL, and it turns out that in that case, the only reason the form submission stays within the overlay under normal operation is due to JavaScript. So there's no way to write a test that will pass. (And I couldn't come up with a simple way to remove the explicit $form['#action'] either.)
I'm attaching my efforts anyway, though. The one without the tests is the one that might be committable (I tweaked the code comments a bit as well; otherwise it is the same as the earlier patches here).
Comment #15
Bojhan CreditAttribution: Bojhan commentedNot sure why this was demoted, we can't have the whole model of the interaction change once you decide to add a module.
Comment #16
andymartha CreditAttribution: andymartha commentedHey, nice simple fix David_Rothstein!
I can confirm that after applying patch overlay-modules-form-submit-1788888-14.patch from David_Rothstein in #14, the modules page stays in the overlay after changing a module status, and it doesn't seem to affect the site with/without the overlay. Would like more tests or opinion, but how?
Comment #17
xjmComment #18
xjmThe passing patch is the one that doesn't include test coverage, unfortunately.
Comment #19
xjmPossible duplicate: #1116326: Support admin overlay in exposed forms
We might want to look at the patch there as well?
Comment #20
David_Rothstein CreditAttribution: David_Rothstein commentedWell, it still looks like a JavaScript bug to me, so no tests, unless we change the modules form to turn it into a PHP bug (but like I said I didn't see an easy way to do that, and it seems a bit out of scope).
I think the other issue is about method=get forms only?
Comment #21
David_Rothstein CreditAttribution: David_Rothstein commentedSince the fix is on the PHP end, though, I guess it would be possible to write some kind of test that ensures this particular function retains its memory after caches are flushed, something like that.
Comment #22
attiks CreditAttribution: attiks commentedclosed #1999218: Help text disappears before being read as a duplicate, this confuses people :/
Comment #23
malcomio CreditAttribution: malcomio commentedthe patch http://drupal.org/files/overlay-modules-form-submit-1788888-14.patch works for me - tested in Chrome & Firefox on Windows
Comment #24
evanmwillhite CreditAttribution: evanmwillhite commentedConfirmed - same patch works for me - tested in Chrome/Firefox on Mac
Comment #25
mariagwyn CreditAttribution: mariagwyn commentedIn attempting to validate this per officehours task (http://core.drupalofficehours.org/task/2046), we confirmed that the patch above (overlay-modules-form-submit-1788888-14.patch) DOES NOT fix admin views with exposed filters in overlay (http://drupal.org/node/1116326)
Assisted by: pixlkat
Steps Taken:
Comment #26
David_Rothstein CreditAttribution: David_Rothstein commentedThanks for testing!
The goal of this patch isn't to fix that :) That's what the other issue is for. They are separate bugs with separate causes.
Excellent. Moving back to "needs review".
Comment #27
mariagwyn CreditAttribution: mariagwyn commentedDuh. Believe it or not I woke up in the middle of last night realizing that we posted the review on the wrong issue.
Comment #28
David_Rothstein CreditAttribution: David_Rothstein commentedAh, I see, that makes sense. It does look like the two issues have been cross-linked a lot, so it's good to finally be sure (thanks to this testing) that they have different causes. Thanks and sorry for your lost sleep :)
Comment #29
sjbassett CreditAttribution: sjbassett commentedSuccess. Tested the overlay-modules-form-submit-1788888-14.patch. Seems good to me to commit.
Comment #30
sjbassett CreditAttribution: sjbassett commentedJust wanted to confirm. I am following the directions from [Drupal Mentoring](http://drupalmentoring.org/task/2046).
Steps taken:
* Set up fresh install of latest version of drupal-8.x
* Tested the error described in:
* http://drupal.org/node/1116326
Confirmed that the patch: overlay-modules-form-submit-1788888-14.patch from Comment #14 resolved both issues.
Comment #31
pplantinga CreditAttribution: pplantinga commentedConfirm that this issue exists and that the patch fixes it.
Looks good to me!
Comment #32
alexpottI don't think we should be testing php language features... ie. the use of static to preserve multiple calls... so until we have js testing this untestable.
Committed f50aa0f and pushed to 8.x. Thanks!
Comment #33.0
(not verified) CreditAttribution: commentedAdding info on cause and potential solutions