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
This commit is contained in:
Sam Minnee 2009-09-24 06:11:02 +00:00
parent 45fb4e0182
commit 2402f308e1

View File

@ -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);