mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fixed default locale setting in SiteTree_Live through Translatable->requireDefaultRecords()
BUGFIX Added translation groups for existing entries the first time Translatable is switched on through Translatable->requireDefaultRecords() (see #4051) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@76866 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
fdcaba515c
commit
9790c4832a
@ -529,18 +529,27 @@ class Translatable extends DataObjectDecorator {
|
||||
ClassInfo::baseDataClass($this->owner->class)
|
||||
))->column();
|
||||
if($idsWithoutLocale) {
|
||||
foreach($idsWithoutLocale as $id) {
|
||||
$obj = DataObject::get_by_id($this->owner->class, $id);
|
||||
$obj->Locale = Translatable::default_locale();
|
||||
$obj->write();
|
||||
$obj->destroy();
|
||||
unset($obj);
|
||||
foreach(array('Stage', 'Live') as $stage) {
|
||||
foreach($idsWithoutLocale as $id) {
|
||||
$obj = Versioned::get_one_by_stage(
|
||||
$this->owner->class,
|
||||
$stage,
|
||||
sprintf('"SiteTree"."ID" = %d', $id)
|
||||
);
|
||||
if(!$obj) continue;
|
||||
|
||||
$obj->Locale = Translatable::default_locale();
|
||||
$obj->writeToStage($stage);
|
||||
$obj->addTranslationGroup($obj->ID);
|
||||
$obj->destroy();
|
||||
unset($obj);
|
||||
}
|
||||
Database::alteration_message(sprintf(
|
||||
"Added default locale '%s' to table %s","changed",
|
||||
Translatable::default_locale(),
|
||||
$this->owner->class
|
||||
));
|
||||
}
|
||||
Database::alteration_message(sprintf(
|
||||
"Added default locale '%s' to table %s","changed",
|
||||
Translatable::default_locale(),
|
||||
$this->owner->class
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -928,16 +937,21 @@ class Translatable extends DataObjectDecorator {
|
||||
$baseDataClass,
|
||||
$baseDataClass
|
||||
);
|
||||
|
||||
$currentStage = Versioned::current_stage();
|
||||
if($this->owner->hasExtension("Versioned")) {
|
||||
if($stage) Versioned::reading_stage($stage);
|
||||
$translations = Versioned::get_by_stage($this->owner->class, Versioned::current_stage(), $filter, null, $join);
|
||||
$translations = Versioned::get_by_stage(
|
||||
$this->owner->class,
|
||||
Versioned::current_stage(),
|
||||
$filter,
|
||||
null,
|
||||
$join
|
||||
);
|
||||
if($stage) Versioned::reading_stage($currentStage);
|
||||
} else {
|
||||
$translations = DataObject::get($this->owner->class, $filter, null, $join);
|
||||
}
|
||||
|
||||
|
||||
self::$enable_lang_filter = true;
|
||||
|
||||
return $translations;
|
||||
|
Loading…
Reference in New Issue
Block a user