From 4c3d97537e7a6f18755546523aab0d23dd5491f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Maa=C3=9F?= Date: Sat, 23 Mar 2013 14:09:50 +0100 Subject: [PATCH] FIX: getTranslations should not change the locale-filter-state If the locale-filter was disabled before calling the method, it would be enabled after calling getTranslations, this commit now only re-enabled the locale-filter if it was enabled before calling the method... --- code/model/Translatable.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/code/model/Translatable.php b/code/model/Translatable.php index 8d435ef..e1aca39 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -1165,8 +1165,15 @@ class Translatable extends DataExtension implements PermissionProvider { if($this->owner->exists()) { // HACK need to disable language filtering in augmentSQL(), // as we purposely want to get different language - self::disable_locale_filter(); - + // also save state of locale-filter, revert to this state at the + // end of this method + $localeFilterEnabled = false; + if(self::locale_filter_enabled()) + { + self::disable_locale_filter(); + $localeFilterEnabled = true; + } + $translationGroupID = $this->getTranslationGroup(); $baseDataClass = ClassInfo::baseDataClass($this->owner->class); @@ -1195,7 +1202,11 @@ class Translatable extends DataExtension implements PermissionProvider { ->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause); } - self::enable_locale_filter(); + // only re-enable locale-filter if it was enabled at the beginning of this method + if($localeFilterEnabled) + { + self::enable_locale_filter(); + } return $translations; }