Merge remote-tracking branch 'origin/2.2' into 2.3

This commit is contained in:
Guy 2018-06-19 10:09:17 +12:00
commit 4cf60e9393
No known key found for this signature in database
GPG Key ID: A80F9ACCB86D3DA7
2 changed files with 5 additions and 14 deletions

View File

@ -1,6 +1,7 @@
# Translatable module for SilverStripe CMS # # Translatable module for SilverStripe CMS #
[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-translatable.png?branch=2.1)](http://travis-ci.org/silverstripe/silverstripe-translatable) [![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-translatable.png?branch=2.1)](http://travis-ci.org/silverstripe/silverstripe-translatable)
[![SilverStripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
## Introduction ## ## Introduction ##

View File

@ -933,13 +933,7 @@ class Translatable extends DataExtension implements PermissionProvider {
// This is to prevent the overhead of writing all translations when // This is to prevent the overhead of writing all translations when
// the class didn't actually change. // the class didn't actually change.
$baseDataClass = ClassInfo::baseDataClass($this->owner->class); $baseDataClass = ClassInfo::baseDataClass($this->owner->class);
$currentStage = Versioned::current_stage(); $fresh = DataObject::get($baseDataClass)->byId($this->owner->ID);
$fresh = Versioned::get_one_by_stage(
$baseDataClass,
Versioned::current_stage(),
'"'.$baseDataClass.'"."ID" = ' . $this->owner->ID,
null
);
if ($fresh) { if ($fresh) {
$changed = $changedFields['ClassName']['after'] != $fresh->ClassName; $changed = $changedFields['ClassName']['after'] != $fresh->ClassName;
} }
@ -1300,20 +1294,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);
} }