Group_update doesn't create groups
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Expired
|
Undecided
|
Unassigned |
Bug Description
Mahara version 1.9.1:
According to the doc:
/**
* Update details of an existing group.
*
* @param array $new New values for the group table.
* @param bool $create Create the group if it doesn't exist yet
*/
function group_update($new, $create=false)
the $create boolean determines if Mahra should create the group if the id provided doesn't match any other but everytime it doesnt find one, it directly throws the "group_update: group not found"
I think it's because the following code:
if (!empty($new->id)) {
$old = get_record_
}
else if (!empty(
$old = get_record_select(
);
if (!$old && $create) {
return group_create(
}
}
if (!$old) {
throw new NotFoundExcepti
}
should look like this:
if (!empty($new->id)) {
$old = get_record_
}
else if (!empty(
$old = get_record_select(
);
}
if (!$old && $create) {
return group_create(
}
if (!$old) {
throw new NotFoundExcepti
}
with the "if (!$old && $create)" conditional OUT of the previous one. I tried it and it works fine now.
Also, I don't know if this is another bug or intentional but, when an id is provided, and create is "true", shouldn't it create it with the ID PROVIDED, instead of an arbitrary one? Because right now it gives you an arbitrary one (since that's what group_create() does).
Daniel, for Mahara 16.10 we made a bunch of changes to the group updates. Now all groups will have short names and can be updated via a CSV file. If your problem still persists, please let us know.