MINOR Merged from trunk

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@79211 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-06-15 05:04:30 +00:00 committed by Sam Minnee
parent 641c565353
commit 059d05bae4
2 changed files with 28 additions and 2 deletions

View File

@ -733,8 +733,15 @@ class Translatable extends DataObjectDecorator {
* Remove the record from the translation group mapping.
*/
function onBeforeDelete() {
$this->removeTranslationGroup();
// @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();
}

View File

@ -131,6 +131,25 @@ class TranslatableTest extends FunctionalTest {
$enPage->ID
);
}
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');