From 5984e62e4568648e903fbf40f1e5c65b2e276735 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 9 Mar 2010 02:34:09 +0000 Subject: [PATCH] BUGFIX Workarounds for GroupSubsites::augmentSQL() so that it doesn't fail on databases other than MySQL like SQL Server --- code/GroupSubsites.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/GroupSubsites.php b/code/GroupSubsites.php index b211e9b..2952620 100644 --- a/code/GroupSubsites.php +++ b/code/GroupSubsites.php @@ -132,13 +132,15 @@ class GroupSubsites extends DataObjectDecorator implements PermissionProvider { = \"Group\".\"ID\" AND \"Group_Subsites\".\"SubsiteID\" = $subsiteID"); $query->where[] = "(\"Group_Subsites\".\"SubsiteID\" IS NOT NULL OR \"Group\".\"AccessAllSubsites\" = 1)"; - - if(!$query->groupby) $query->groupby[] = "\"Group\".\"ID\""; } else { $query->where[] = "\"Group\".\"AccessAllSubsites\" = 1"; } } - $query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby; + + // WORKAROUND for databases that complain about an ORDER BY when the column wasn't selected (e.g. SQL Server) + if(!$query->select[0] == 'COUNT(*)') { + $query->orderby = "\"AccessAllSubsites\" DESC" . ($query->orderby ? ', ' : '') . $query->orderby; + } } }