From 7dc8205ae55385ea587ebb546c51fb878ee88cea Mon Sep 17 00:00:00 2001 From: AFS Date: Tue, 8 Oct 2019 23:06:17 +0200 Subject: [PATCH 1/2] Prevent error when session has expired When using the 'back' route and the session expired between last page visit and language switch, it produces the error 'Object of class Illuminate\Routing\Redirector could not be converted to string'. This patch uses $session->previousUrl() only if set, if not it goes back to home. --- src/Controllers/Language.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Controllers/Language.php b/src/Controllers/Language.php index 0fd97fd..e812403 100644 --- a/src/Controllers/Language.php +++ b/src/Controllers/Language.php @@ -72,7 +72,10 @@ public function back($locale, Request $request) $session->setPreviousUrl($url); } - - return redirect($session->previousUrl()); + return redirect( + $session->previousUrl() + ? $session->previousUrl() + : ( config('language.url') ? url('/' . $locale) : url('/') ) + ); } } From 2b5202ea8ea59a83296cc6e4fe924a4638697767 Mon Sep 17 00:00:00 2001 From: AFS Date: Tue, 8 Oct 2019 23:08:50 +0200 Subject: [PATCH 2/2] CI fix --- src/Controllers/Language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controllers/Language.php b/src/Controllers/Language.php index e812403..0b52ace 100644 --- a/src/Controllers/Language.php +++ b/src/Controllers/Language.php @@ -75,7 +75,7 @@ public function back($locale, Request $request) return redirect( $session->previousUrl() ? $session->previousUrl() - : ( config('language.url') ? url('/' . $locale) : url('/') ) + : (config('language.url') ? url('/' . $locale) : url('/')) ); } }