Problem/Motivation

The initial ajax response (when clicking 'Next' the first time) doesn't seem to contain an AnnounceCommand. It also generates a PHP session for the anonymous user. This is troublesome because users with open sessions (SESS* cookie) will normally bypass CDNs and other full page caching systems (can happen if the user navigates away from a form when they have a session).

I'm thinking this might be a two-birds-with-one-stone issue.

  • Ajax wizard forms do not seem to consistently utilize Drupal.announce as expected.
  • Every other step through a wizard form as an anonymous user generates a PHP session for said user.

Steps to reproduce

What I would expect to happen is:

  1. Load up an ajax wizard form.
  2. Assert that #drupal-live-announce is empty
  3. Click 'Next'
  4. Assert that #drupal-live-announce now contains "Test: Webform: Wizard basic: Step 2" loaded. (2 of 4)
  5. Click 'Previous
  6. Assert that #drupal-live-announce now contains "Test: Webform: Wizard basic: Step 1" loaded. (1 of 4)

What really seems to happen is:

  1. Load up an ajax wizard form.
  2. #drupal-live-announce is empty
  3. Click 'Next'
  4. #drupal-live-announce is empty
  5. Click 'Previous
  6. #drupal-live-announce now contains
    "Test: Webform: Wizard basic: Step 2" loaded. (2 of 4)
    "Test: Webform: Wizard basic: Step 1" loaded. (1 of 4)

Proposed resolution

I think the path forward here might involve not storing the announcement in the user's session, but rather in memory (perhaps drupal_static or \Drupal\Core\Cache\MemoryCache\MemoryCache?

Remaining tasks

Make the patch beautiful. The service should probably be injected somehow / somewhere. I wasn't sure what the best way to approach it was because the service is needed within a trait. Procedurally grabbing the service is not an optimal approach.

Does the test require a new test form, or is there an existing one that can/should be used? If an existing form can be used, then there'd be less patch noise.

User interface changes

None

API changes

Perhaps a new service if the memory cache service is preferable, otherwise none if drupal_static is used.

Data model changes

None

Comments

Luke.Leber created an issue. See original summary.

luke.leber’s picture

StatusFileSize
new7.54 KB
luke.leber’s picture

StatusFileSize
new7.54 KB
luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

StatusFileSize
new7.54 KB

It really does help if the test group is spelled correctly...time for a nap.

luke.leber’s picture

StatusFileSize
new7.53 KB
luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

Title: Accessibility: ajax wizard forms do not consistently utilize Drupal.announce » Accessibility: ajax wizard forms do not consistently utilize Drupal.announce | Sessions generated for anonymous users?

Update - I think that I've been able to track down a contributing factor to this conundrum.

\Drupal\webform\src\Form\WebformAjaxFormTrait::setAnnouncements seems to initiate a session for would-be anonymous users (sometimes).

As a result, when a user first visits a form, they do not have a PHP session. If they proceed to the second step, then a session is created for them and the announcement seems to be stored in it. If they proceed again, then the announcement seems to be picked up and sent back as part of the ajax request. The session is then terminated (nothing left in it after \Drupal\webform\src\Form\WebformAjaxFormTrait::resetAnnouncements is called!

I think the path forward here might involve not storing the announcement in the user's session, but rather in memory (perhaps drupal_static or \Drupal\Core\Cache\MemoryCache\MemoryCache?

Switching from session based storage to the memory cache seems to take care of the original problem.

I'll try to get a patch uploaded this weekend.

I think the title is a bit confusing -- I might only be seeing a symptom of an underlying problem with Drupal.announce not working properly.

luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

StatusFileSize
new9.36 KB

I don't think that the new test is going to run...but hopefully I've added enough info to this issue to help!

Cheers!

luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

luke.leber’s picture

luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

Removing Needs a11y review tag -- I actually think this is for core issues only...but an accessibility review wouldn't hurt :)

luke.leber’s picture

StatusFileSize
new9.36 KB

Fixed namespace in the new test...

luke.leber’s picture

Issue summary: View changes
luke.leber’s picture

Status: Active » Needs review
luke.leber’s picture

Issue summary: View changes
jrockowitz’s picture

StatusFileSize
new1.75 KB

MemoryCache is not unique to each user and concurrent users might receive the wrong announcement.

Using a static property is not working as expected. (See attached patch)

jrockowitz’s picture

StatusFileSize
new3.19 KB

Using drupal_static works because the announcement property is being serialized with the form object via the Ajax request.

I don't think we need a new dedicated webform to test this behavior and I moved the new tests into WebformWizardBasicJavaScriptTest

luke.leber’s picture

That patch looks awesome and seems to resolve the originally reported issue. +1 RTBC from me.

luke.leber’s picture

Status: Needs review » Reviewed & tested by the community
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • jrockowitz authored 630d26d on 8.x-5.x
    Issue #3178298 by Luke.Leber, jrockowitz: Accessibility: ajax wizard...

  • jrockowitz authored 630d26d on 6.x
    Issue #3178298 by Luke.Leber, jrockowitz: Accessibility: ajax wizard...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.