mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #39875
[Bug 1355761] Re: Group_update doesn't create groups
[Expired for Mahara because there has been no activity for 60 days.]
** Changed in: mahara
Status: Incomplete => Expired
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1355761
Title:
Group_update doesn't create groups
Status in Mahara:
Expired
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_select('group', 'id = ? AND deleted = 0', array($new->id));
}
else if (!empty($new->institution) && isset($new->shortname) && strlen($new->shortname)) {
$old = get_record_select(
'group',
'shortname = ? AND institution = ? AND deleted = 0',
array($new->shortname, $new->institution)
);
if (!$old && $create) {
return group_create((array)$new);
}
}
if (!$old) {
throw new NotFoundException("group_update: group not found");
}
should look like this:
if (!empty($new->id)) {
$old = get_record_select('group', 'id = ? AND deleted = 0', array($new->id));
}
else if (!empty($new->institution) && isset($new->shortname) && strlen($new->shortname)) {
$old = get_record_select(
'group',
'shortname = ? AND institution = ? AND deleted = 0',
array($new->shortname, $new->institution)
);
}
if (!$old && $create) {
return group_create((array)$new);
}
if (!$old) {
throw new NotFoundException("group_update: group not found");
}
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).
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1355761/+subscriptions
References