Merge pull request #1342 from mejt/3

Added avoiding unhandled exception from Translatable extension in ContentController
This commit is contained in:
Damian Mooyman 2015-12-22 16:58:04 +13:00
commit 43a855e5b5

View File

@ -155,8 +155,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);