mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Merge pull request #278 from creative-commoners/pulls/2.2/fix-invalid-stage
BUG Fix invalid stage being specified for queried records
This commit is contained in:
commit
b8d794a5c2
@ -1295,20 +1295,16 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
// exclude the language of the current owner
|
// exclude the language of the current owner
|
||||||
$filter .= sprintf(' AND "%s"."Locale" != \'%s\'', $baseDataClass, $this->owner->Locale);
|
$filter .= sprintf(' AND "%s"."Locale" != \'%s\'', $baseDataClass, $this->owner->Locale);
|
||||||
}
|
}
|
||||||
$currentStage = Versioned::current_stage();
|
|
||||||
$joinOnClause = sprintf('"%s_translationgroups"."OriginalID" = "%s"."ID"', $baseDataClass, $baseDataClass);
|
$joinOnClause = sprintf('"%s_translationgroups"."OriginalID" = "%s"."ID"', $baseDataClass, $baseDataClass);
|
||||||
if($this->owner->hasExtension("Versioned")) {
|
if($this->owner->hasExtension("Versioned") && $stage) {
|
||||||
if($stage) Versioned::reading_stage($stage);
|
|
||||||
$translations = Versioned::get_by_stage(
|
$translations = Versioned::get_by_stage(
|
||||||
$baseDataClass,
|
$baseDataClass,
|
||||||
Versioned::current_stage(),
|
$stage,
|
||||||
$filter,
|
$filter,
|
||||||
null
|
null
|
||||||
)->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
|
)->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
|
||||||
if($stage) Versioned::reading_stage($currentStage);
|
|
||||||
} else {
|
} else {
|
||||||
$class = $this->owner->class;
|
$translations = DataObject::get($baseDataClass)
|
||||||
$translations = $baseDataClass::get()
|
|
||||||
->where($filter)
|
->where($filter)
|
||||||
->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
|
->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user