Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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...
  • Loading branch information...
commit 9579748e137cec1d740ecd3a62dde6473f4bb2f7 1 parent fb15dae
Steffen Maaß authored chillu committed
Showing with 12 additions and 3 deletions.
  1. +12 −3 code/model/Translatable.php
View
15 code/model/Translatable.php
@@ -1166,8 +1166,14 @@ function getTranslations($locale = null, $stage = null) {
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 @@ function getTranslations($locale = null, $stage = null) {
->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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.