BUGFIX Don't set SubsiteID from DataObject::context_obj() if its NULL in SiteTreeSubsites->augmentSQL()

This commit is contained in:
Ingo Schommer 2009-10-16 01:10:52 +00:00
parent 79bedca43b
commit f6706c16ed

View File

@ -57,7 +57,8 @@ class SiteTreeSubsites extends DataObjectDecorator {
// If you're querying by ID, ignore the sub-site - this is a bit ugly... // If you're querying by ID, ignore the sub-site - this is a bit ugly...
if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) { if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) {
if($context = DataObject::context_obj()) $subsiteID = (int) $context->SubsiteID; $context = DataObject::context_obj();
if($context && is_numeric($context->SubsiteID)) $subsiteID = (int) $context->SubsiteID;
else $subsiteID = (int) Subsite::currentSubsiteID(); else $subsiteID = (int) Subsite::currentSubsiteID();
// The foreach is an ugly way of getting the first key :-) // The foreach is an ugly way of getting the first key :-)