mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Fixed Translatable->requireDefaultRecords() for non-SiteTree objects (was assuming Versioned to be present)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@78729 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
2f020b5c83
commit
601672cdff
@ -526,7 +526,9 @@ class Translatable extends DataObjectDecorator {
|
||||
'SELECT "ID" FROM "%s" WHERE "Locale" IS NULL OR "Locale" = \'\'',
|
||||
ClassInfo::baseDataClass($this->owner->class)
|
||||
))->column();
|
||||
if($idsWithoutLocale) {
|
||||
if(!$idsWithoutLocale) return;
|
||||
|
||||
if($this->owner->class == 'SiteTree') {
|
||||
foreach(array('Stage', 'Live') as $stage) {
|
||||
foreach($idsWithoutLocale as $id) {
|
||||
$obj = Versioned::get_one_by_stage(
|
||||
@ -535,20 +537,31 @@ class Translatable extends DataObjectDecorator {
|
||||
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
|
||||
));
|
||||
}
|
||||
} else {
|
||||
foreach($idsWithoutLocale as $id) {
|
||||
$obj = DataObject::get_by_id($this->owner->class, $id);
|
||||
if(!$obj) continue;
|
||||
|
||||
$obj->Locale = Translatable::default_locale();
|
||||
$obj->write();
|
||||
$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
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user