mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Don't remove translation groups in Translatable->onBeforeDelete() if the decorated record uses Versioned, as other representations of the record might still exist in other tables (e.g. SiteTree_Live) (see #4219)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79208 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9c1ef3cd15
commit
20ada72b4d
@ -737,7 +737,14 @@ class Translatable extends DataObjectDecorator {
|
||||
* Remove the record from the translation group mapping.
|
||||
*/
|
||||
function onBeforeDelete() {
|
||||
// @todo Coupling to Versioned, we need to avoid removing
|
||||
// translation groups if records are just deleted from a stage
|
||||
// (="unpublished"). Ideally the translation group tables would
|
||||
// be specific to different Versioned changes, making this restriction unnecessary.
|
||||
// This will produce orphaned translation group records for SiteTree subclasses.
|
||||
if(!$this->owner->hasExtension('Versioned')) {
|
||||
$this->removeTranslationGroup();
|
||||
}
|
||||
|
||||
parent::onBeforeDelete();
|
||||
}
|
||||
|
@ -136,6 +136,25 @@ class TranslatableTest extends FunctionalTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testTranslationGroupNotRemovedWhenSiteTreeUnpublished() {
|
||||
$enPage = new Page();
|
||||
$enPage->Locale = 'en_US';
|
||||
$enPage->write();
|
||||
$enPage->publish('Stage', 'Live');
|
||||
$enTranslationGroup = $enPage->getTranslationGroup();
|
||||
|
||||
$frPage = $enPage->createTranslation('fr_FR');
|
||||
$frPage->write();
|
||||
$frPage->publish('Stage', 'Live');
|
||||
$frTranslationGroup = $frPage->getTranslationGroup();
|
||||
|
||||
$enPage->doUnpublish();
|
||||
$this->assertEquals($enPage->getTranslationGroup(), $enTranslationGroup);
|
||||
|
||||
$frPage->doUnpublish();
|
||||
$this->assertEquals($frPage->getTranslationGroup(), $frTranslationGroup);
|
||||
}
|
||||
|
||||
function testGetTranslationOnSiteTree() {
|
||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user