From 2402f308e17d3b67828ac0aa0dbc4d10b6bcfae8 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 24 Sep 2009 06:11:02 +0000 Subject: [PATCH] BUGFIX: Fixed bug in recent changes to Hierarchy::liveChildren() to do with Translatable git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@87228 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Hierarchy.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/model/Hierarchy.php b/core/model/Hierarchy.php index c497e1c9e..2ed2bd6e0 100644 --- a/core/model/Hierarchy.php +++ b/core/model/Hierarchy.php @@ -530,13 +530,15 @@ class Hierarchy extends DataObjectDecorator { $oldStage = Versioned::current_stage(); Versioned::reading_stage('Live'); - $query = $this->owner->extendedSQL($filter, null, null, $join); + // Singleton is necessary and not $this->owner so as not to muck with Translatable's + // behaviour. + $query = singleton($baseClass)->extendedSQL($filter, null, null, $join); // Since we didn't include double quotes in the join & filter, we need to add them into the // SQL now, after Versioned has done is query rewriting $correctedSQL = str_replace(array("LEFT JOIN {$baseClass}", "{$baseClass}.\"ID\""), array("LEFT JOIN \"{$baseClass}\"", "\"{$baseClass}\".\"ID\""), $query->sql()); - + $result = $this->owner->buildDataObjectSet(DB::query($correctedSQL)); Versioned::reading_stage($oldStage);