Permalink
Browse files

MINOR Merged from trunk

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@79211 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 641c565 commit 059d05bae4adae965c10caafbd0b1be525796024 @chillu chillu committed with sminnee Jun 15, 2009
Showing with 28 additions and 2 deletions.
  1. +9 −2 core/model/Translatable.php
  2. +19 −0 tests/model/TranslatableTest.php
View
11 core/model/Translatable.php
@@ -733,8 +733,15 @@ function onAfterWrite() {
* 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
19 tests/model/TranslatableTest.php
@@ -131,6 +131,25 @@ function testTranslationGroups() {
$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');

0 comments on commit 059d05b

Please sign in to comment.