From b8b9f4e2dfc96b24dba715f1ea3213021f02ecfb Mon Sep 17 00:00:00 2001 From: thomas83 Date: Thu, 12 Nov 2015 01:23:09 +0800 Subject: [PATCH 1/2] Fix Issue #255 when a localization is removed When a localization has been removed from the system, leaving end-user in a broken cookie session. --- .../LaravelLocalization/Middleware/LocaleSessionRedirect.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mcamara/LaravelLocalization/Middleware/LocaleSessionRedirect.php b/src/Mcamara/LaravelLocalization/Middleware/LocaleSessionRedirect.php index 3d0f93a..73ed21c 100644 --- a/src/Mcamara/LaravelLocalization/Middleware/LocaleSessionRedirect.php +++ b/src/Mcamara/LaravelLocalization/Middleware/LocaleSessionRedirect.php @@ -26,7 +26,7 @@ public function handle( $request, Closure $next ) $locale = session('locale', false); - if ( $locale && !( app('laravellocalization')->getDefaultLocale() === $locale && app('laravellocalization')->hideDefaultLocaleInURL() ) ) + if ( $locale && app('laravellocalization')->checkLocaleInSupportedLocales($locale) && !( app('laravellocalization')->getDefaultLocale() === $locale && app('laravellocalization')->hideDefaultLocaleInURL() ) ) { app('session')->reflash(); $redirection = app('laravellocalization')->getLocalizedURL($locale); @@ -36,4 +36,4 @@ public function handle( $request, Closure $next ) return $next($request); } -} \ No newline at end of file +} From c7f7c790ad2a2aa3c33b95a496dc50bf734c3a60 Mon Sep 17 00:00:00 2001 From: Mahdi Ghadamyari Date: Sat, 14 Nov 2015 01:50:22 +0330 Subject: [PATCH 2/2] Update LanguageNegotiator.php There is not any array that named $array --- src/Mcamara/LaravelLocalization/LanguageNegotiator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mcamara/LaravelLocalization/LanguageNegotiator.php b/src/Mcamara/LaravelLocalization/LanguageNegotiator.php index 2877f0b..19315bc 100644 --- a/src/Mcamara/LaravelLocalization/LanguageNegotiator.php +++ b/src/Mcamara/LaravelLocalization/LanguageNegotiator.php @@ -65,7 +65,7 @@ public function negotiateLanguage() { reset($this->supportedLanguages); - return key($array); + return key($this->supportedLanguages); } if ( class_exists('Locale') && !empty( $_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ] ) ) @@ -154,4 +154,4 @@ private function getMatchesFromAcceptedLanguages() return $matches; } -} \ No newline at end of file +}