-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[5.8] Previous URL in Session contains current full URL #27731
Comments
The way it works currently is correct. The problem with your example is that in context of a test you're switching the url of the current session of a test instead of the session when the route is called. This works: Route::get('/', function () {
session()->setPreviousUrl($previousUrl = 'https://www.example.com/foo/bar/');
return response(session()->previousUrl());
}); |
@driesvints, you're right, I setup my test wrong. But how about when the session already contains a previous url like the example given below.
Here the previous url is set by some previous request and when calling
|
@tswestendorp you shouldn't perform two route calls in the same test. Use separate test methods. |
@driesvints There are some issue when using laravel browserkit tests though: Given some controller route with a <?php
public function archive($model)
{
$model->archive();
return redirect()->back();
} And a browserkit test: <?php
$this->actingAs($user)
->visit('model.show')
->click('archive')
->see(...) You run into an infinite redirect on Laravel 5.8, rapidly filling up your storage/framework/session directory with session files. I do think short test methods is a great "best practice" advise, but when using some functional testing to tie important things together you easily run into problems with this change. The whole purpose of the |
@okdewit can you create an issue on the browser kit testing repo with a full example of how this breaks? |
My issue was fixed by #27935 in Laravel 5.8.5 👍 |
Description:
session()->previousUrl()
contains the current$request->fullUrl()
instead of the real previous url.Current situation is that
\Illuminate\Session\Middleware\StartSession::storeCurrentUrl()
is called before$next($request)
is called, I would assume that the response should have been generated before storing the current url.Steps To Reproduce:
Generates
The text was updated successfully, but these errors were encountered: