laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.44k stars 11k forks source link

DB::beginTransaction() without DB::rollBack() disables flash messages. #27956

Closed poldon closed 5 years ago

poldon commented 5 years ago

Description:

If I call DB::beginTransaction() in a controller but redirect without calling DB::rollBack(), my flash messages don't appear on the new page. For example, in a shopping cart, I start a transaction but redirect to the payment page when the credit card payment fails. The payment error doesn't appear unless I call DB::rollBack() first. This happens on both Laravel 5.7 and 5.8.

Steps To Reproduce:

This fails:

    DB::beginTransaction();

    return redirect("/checkout/payment")->withInput($request->all())->withFlashDanger("Credit Card Number is required.");

This works:

    DB::beginTransaction();

    DB::rollBack();

    return redirect("/checkout/payment")->withInput($request->all())->withFlashDanger("Credit Card Number is required.");
driesvints commented 5 years ago

Can you first please try one of the following support channels? If you can actually identify this as a bug, feel free to report back.

poldon commented 5 years ago

I still believe the underlying issue is a bug. I posted on Stack Overflow, but I don't believe it's going to get any helpful answers: https://stackoverflow.com/questions/55282166/flash-messages-dont-work-during-db-transactions-in-laravel-5-7-and-5-8

My concern is that there may be other session-related data that isn't getting set during a transaction.

medeirosinacio commented 2 years ago

i have this same problem. 😥

oussema9slimi commented 10 months ago

i have this same problem. 😥

Have you found a solution for this problem, I'm facing the same problem too...