"Session has not been set" when loading a form in ajax wrapper in D10.3 or higher

Created on 30 August 2024, 3 months ago

Problem/Motivation

"Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Session has not been set" when loading a form in ajax wrapper in D10.3 or higher

Steps to reproduce

Load a form in the ajax wrapper callback. You get the error "Session has not been set".

Proposed resolution

Add the session before pushing a new request?

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇧🇪Belgium victonator

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @victonator
  • 🇧🇪Belgium victonator

    Not sure if correct way to fix, but this patch works for me

  • Status changed to Needs review 2 months ago
  • 🇧🇪Belgium mauro_

    @victonator I've not encountered the issue with the wrapper so far on 10.3, but I don't think I have forms that load through AJAX wrapper.

    If I understand the issue correctly the form is what requires a session and not ajax wrapper? If so, the session should probably be initiated somewhere in the form and not in AJAX wrapper. Correct me if I'm wrong though :)

  • 🇧🇪Belgium victonator

    Hi @mauro_
    In AjaxWrapperController.php:183 a new request is created and later on gets pushed in the requestStack.
    FormBuilder.php requires a session from the currentRequest which is now the new request without a session from ajax_wrapper.
    Adding the session from the mainRequest to the currentRequest (or something like that) is not something I should have to do when building my form in my opinion :) .
    This should be handled in the module in some way, like in the attached patch.

  • 🇧🇪Belgium JeroenT 🇧🇪

    We encountered the same problem on one of our projects.

  • Merge request !5Resolve #3471148 "1.x" → (Merged) created by JeroenT
  • Status changed to RTBC about 16 hours ago
    • jeroent committed f5d7335c on 1.0.x
      Issue #3471148 by jeroent, victonator, mauro_: "Session has not been set...
Production build 0.71.5 2024