Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel flash messages not working after update to 3.13 #1612

Open
cedricpri opened this issue Apr 9, 2024 · 8 comments
Open

Laravel flash messages not working after update to 3.13 #1612

cedricpri opened this issue Apr 9, 2024 · 8 comments

Comments

@cedricpri
Copy link

Hello!

I've been using the debugbar for a while now and I have been quite happy so far, thanks for the hard work!

Anyway, I started having issues with my app last week. After rebuilding the containers (and updating the debugbar to the last version, 3.13.3) my app Laravel/Inertia/App suddenly stopped working. Basically, all the flashed messages from Laravel weren't picked up by Inertia, therefore breaking some features in my app.

In particular, I defined a vue component which simply calls a "/test" endpoint when mounted. This endpoint contains the following code:

public function testMethod()
  {
      session()->put("success", "message1");
      return back()->with("testMessage", "message2");
  }

I then defined an Inertia Middleware to intercept this flashed message and show in the frontend as per their documentation:

public function share(Request $request): array
  {
      return array_merge(parent::share($request), [
          "flash" => function () {
              return [
                  "testMessage" => session()->get("testMessage"),
                  "success" => session()->get("success"),
                  "error" => session()->get("error"),
                  "status" => session()->get("status"),
                  "data" => session()->get("data")
              ];
          },
      ]);
  }

However, the flashed message was never found under any circumstance while this used to work perfectly fine. After a few days of investigations, I realized that reverting the debugbar back to 3.12.4 apparently solves the issue.

Any idea where this behaviour might come from?
Thank you!

@parallels999
Copy link
Contributor

Any idea where this behaviour might come from?

maybe #1591

@cedricpri
Copy link
Author

The session appears to be saved in my case(the success message does show up in my Middleware) but the flashed data doesn't seem to be.

@parallels999
Copy link
Contributor

If you find the problem feel free to open a PR with the fix

@barryvdh
Copy link
Owner

I'm not 100% but I think the moment we add our stacked data to the session, the session is already saved so we re-flash the messages. But it seems that you also try to change it in the middleware, so might be a timing issue. Not really sure what the safest way is.

@barryvdh
Copy link
Owner

I tried the flashing with default Laravel installations and existing project, and there the flash messages keep working + redirect show in the tabs. But not sure about Intertia

@jakublacko
Copy link

@barryvdh We do not have inertia in the project and still after updating to 3.13 all the flash messages stopped working. Downgrade to 3.12 helped for now

@barryvdh
Copy link
Owner

Hmm I've reverted it again. Will try to find something without re-flashing.
#1613

@barryvdh
Copy link
Owner

New attempt in #1657

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants