From 68dd8cf79836133ce1452f617ab7f30d05d44889 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Tue, 8 Dec 2015 08:47:50 +0100 Subject: [PATCH] Added avoiding unhandled exception from Translatable extension in ContentController --- code/controllers/ContentController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php index 11e22cd7..80da9181 100755 --- a/code/controllers/ContentController.php +++ b/code/controllers/ContentController.php @@ -182,8 +182,9 @@ class ContentController extends Controller { // look for a translation and redirect (see #5001). Only happens on the last child in // a potentially nested URL chain. if(class_exists('Translatable')) { - if($request->getVar('locale') && $this->dataRecord && $this->dataRecord->Locale != $request->getVar('locale')) { - $translation = $this->dataRecord->getTranslation($request->getVar('locale')); + $locale = $request->getVar('locale'); + if($locale && i18n::validate_locale($locale) && $this->dataRecord && $this->dataRecord->Locale != $locale) { + $translation = $this->dataRecord->getTranslation($locale); if($translation) { $response = new SS_HTTPResponse(); $response->redirect($translation->Link(), 301);