- Issue created by @timwood
- First commit to issue fork.
- π³π±Netherlands Lendude Amsterdam
Added the proposed code and a test assertion. I can see this happen when testing manually, but the test isn't catching it.
The assertion detects the session when I log a user in a test, so that part works, but in the test, the reset is not triggering the bug. Haven't figured out why yet - Status changed to Needs work
about 1 month ago 1:54pm 3 March 2025 - πΊπΈUnited States tregonia
Currently rubbing up against this issue in D11. I can confirm that the patch does apply, but does not not prevent the anonymous sessions from being created.
- πΊπΈUnited States tregonia
In my instance, I am finding that the code never reaches the
resetForm
function.The call to
resetForm
is on line 292, but does not make it into the if statement. This is due toop
not being in theform_state
within theexposedFormSubmit
function.
https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php#L292 - πΊπΈUnited States timwood Rockville, Maryland
In testing the MR on a 10.3.13 site, I can confirm that the patch applies there and prevents anonymous sessions from being created.
I also tested the 11.x branch on simplytest.me with and without the MR patch. When using the patch, I do not see cookies being set when clicking a reset button. When not using the patch the cookie is still set.
@tregonia how did you validate the anonymous session? Did you use an incognito window or other browser to ensure you didn't already have a cookie?
- πΊπΈUnited States tregonia
@timwood
My process was as follows.- Find a form that includes a reset button and open it in a different browser.
- Ping the database using
drush sql:cli
to get a count on anonymous sessions.
SELECT count(*) FROM sessions WHERE uid = 0;
Also used this to look at them.
SELECT * FROM sessions WHERE uid = 0 ORDER BY timestamp DESC;
- Clicked the reset button.
- Run the 2 sql:cli commands again.
Note the sessions count increases, and a new session is created in the database.
I am currently running D11.1.
- πΊπΈUnited States timwood Rockville, Maryland
Good tip about the DB query before and after. Can you confirm in your browser whether a session cookie was sent with the 303 redirect response to the user after clicking the reset button?
Update issue description to add better ordered list formatting.
- First commit to issue fork.
I was able to the test-only job to fail by changing the test line from
drupalGet
tosubmitForm
, so that a reset button press is actually performed.@tregonia With the MR diff applied, I was not able to reproduce the your reported issue with anonymous session entries in the database table, using the Standard profile install steps detailed in the IS. Are you using any custom or contrib modules that touch forms or views? One other thing to check is to inspect the Reset button in the browser and check whether the
name="op"
attribute is on the button element. If it's not, then something is removing the attribute that core form API adds.- πΊπΈUnited States smustgrave
Left a comment on the MR
If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
- π¬π§United Kingdom catch
Committed/pushed to 11.x and cherry-picked to 10.5.x, thanks!
Automatically closed - issue fixed for 2 weeks with no activity.