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...
This commit is contained in:
Steffen Maaß 2013-03-23 14:09:50 +01:00 committed by Ingo Schommer
parent fb15dae253
commit 9579748e13
1 changed files with 12 additions and 3 deletions

View File

@ -1166,8 +1166,14 @@ 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);
@ -1196,7 +1202,10 @@ 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;
}