Permalink
Browse files

BUGFIX: singleton('Group')->Members() fails

Running Members() on a Group that has no Db record causes UnsavedRelationList to be returned by DirectMembers() which in turn causes alterDataQuery() to fall over when called on an UnsavedRelationList. This just adds a simple check to prevent it.
  • Loading branch information...
1 parent 6394eaf commit d36fbfb1b2bab63ac21c1845672f798bb2ad48fd @nedmas nedmas committed May 23, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 security/Group.php
View
@@ -251,9 +251,11 @@ public function Members($filter = "", $sort = "", $join = "", $limit = "") {
// Remove the default foreign key filter in prep for re-applying a filter containing all children groups.
// Filters are conjunctive in DataQuery by default, so this filter would otherwise overrule any less specific
// ones.
- $result = $result->alterDataQuery(function($query){
- $query->removeFilterOn('Group_Members');
- });
+ if(!($result instanceof UnsavedRelationList)) {
+ $result = $result->alterDataQuery(function($query){
+ $query->removeFilterOn('Group_Members');
+ });
+ }
// Now set all children groups as a new foreign key
$groups = Group::get()->byIDs($this->collateFamilyIDs());
$result = $result->forForeignID($groups->column('ID'))->where($filter)->sort($sort)->limit($limit);

0 comments on commit d36fbfb

Please sign in to comment.