We have moved to Github. Please open tickets there.

Opened 3 years ago

Closed 3 years ago

#1987 closed Defect (worksforme)

subtypes of group and user are returned in elgg_get_entitites with empty subtype

Reported by: dramirez Owned by:
Priority: normal Milestone: Elgg 1.7.1
Component: Groups Version: 1.7
Severity: minor Keywords:
Cc: brettp Difficulty:

Description

Suppose you want to create a group subtype, let say 'projects' you makes something like:
$project = new ElggGroup()
$project->subtype='project';
$project-save();

Now you have groups and projects now try to get a list of projects:

$projects = elgg_get_entitites(array("type"=>"group","subtype"=>'project'));

Here everything ok, now try to get the list of groups

$groups = elgg_get_entitites(array("type"=>"group"));

Now groups have a list of groups AND projects. It is wrong!

It happens because when subtype is blank the SQL generated only checks against the type field so any subtype of users and groups are returned too.

Attachments (2)

groups_empty_subtype.patch (9.3 KB) - added by dramirez 3 years ago.
groups_empty_subtype-core.patch (1.7 KB) - added by dramirez 3 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 3 years ago by brettp

  • Resolution set to invalid
  • Status changed from new to closed

Try to use:

$group = elgg_get_entities(array(
    'type' => 'group',
    'subtype' => ELGG_ENTITIES_NO_VALUE
));

If that doesn't work, please reopen this ticket.

This constant needs to be documented.

comment:2 Changed 3 years ago by dramirez

  • Component changed from Core to Groups
  • Resolution invalid deleted
  • Status changed from closed to reopened

It works!

The problem now is that it is not the default behavior in the groups plugin. When I show my groups it shows my groups AND my projects.

I'll attach a patch latter.

Changed 3 years ago by dramirez

Changed 3 years ago by dramirez

comment:3 Changed 3 years ago by dramirez

  • Type changed from unconfirmed defect to fixed in attachment

Attached patch to groups module and engine/lib/relationships to fix this problem.

comment:4 Changed 3 years ago by cash

  • Priority changed from critical to normal
  • Severity changed from blocker to minor

The group patch appears to have been done off of the trunk (1.8) rather than the 1.7 branch. I can figure out what it is doing but we need decide what we want the default to be.

The options are

  1. groups plugin shows all groups
  2. group plugin shows only groups without subtype

Either way some group of people will have to override some group functionality (unless this is made as a parameter). Some people use subtypes to extend the group plugin but expect them to be listed as groups. Others subtype it and want to separate the subtype from the normal groups.

To override this only requires overriding the group page handler for a few pages if this patch does cover everything.

comment:5 Changed 3 years ago by brettp

What is listed by default was discussed for the context of search in #1499. For consistency, I'd argue the bundled plugins should all function the same way when listing users and groups. With search as precedence, this means to list all regardless of subtype.

comment:6 Changed 3 years ago by cash

I agree. Elgg has worked this way for a while. As long as all the pages go through the page handler, this should be easy to change with a plugin.

Diego, you also submitted a patch on the relationships lib. This should probably be its own ticket (though I haven't taken the time to understand what it is doing).

comment:7 Changed 3 years ago by dramirez

The relationships patch comes with the code for fix the method get_entities_from_relationship that is not using the ELGG_ENTITIES_NO_VALUE parameter. I will open a separate ticket for this.

Talking about the groups plugin I think that both behavior should be available through plugin's configuration. It would give to users the freedom to choose what behavior is better for their context without need to change any core code.

comment:8 Changed 3 years ago by cash

Diego, please don't forgot to open a ticket for the relationship patch and explain what is not working so we can test for it.

comment:9 Changed 3 years ago by cash

  • Resolution set to worksforme
  • Status changed from reopened to closed

I'm closing this one. Diego, don't forget to open a ticket for the relationship patch as I've said before.

Note: See TracTickets for help on using tickets.