Fail deleting long name groups

Bug #1359109 reported by Daniel Parejo on 2014-08-20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Daniel Parejo

Bug Description

When you delete a group, it concatenates '.deleted.'.time() that is about 19 characters. Hence, if your group name is longer than 108 characters it will throw a DB exception for exceeding the 128 characters field for the group name. To avoid this, I've added the following code to function group_delete($groupid, $shortname=null, $institution=null, $notifymembers=true):

//Daniel Parejo
    $delete_name = $group->name;
    if (strlen($delete_name) > 100) {
        $delete_name = substr($delete_name, 0, 100) . '(...)';
//End added code

            'deleted' => 1,
            'name' => $delete_name . '.deleted.' . time(), //modified code
            'shortname' => null,
            'institution' => null,
            'category' => null,
            'urlid' => null,
            'id' => $group->id,

This solution is not perfect since it will fail if two groups that are not different in their 101 first characters are tried to be removed in the same time instant. Still, way better than before, though I think a more solid solution should be implemented.

description: updated
tags: added: groups

Hi Daniel,

Thank you for your patch. Do you want to put it into our review system at yourself or want one of our developers to do that?

Instructions for getting started with Gerrit, the review system, are at


Changed in mahara:
status: New → In Progress
assignee: nobody → Daniel Parejo (danielparejom)
importance: Undecided → Medium
tags: added: patch
removed: delete group
Robert Lyon (robertl-9) on 2015-02-16
Changed in mahara:
milestone: none → 15.04.0

Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 3f6c7f8001e7c4663ad48f92bc1a14d96e5d72dc
Author: Daniel Parejo <email address hidden>
Date: Tue Feb 17 12:14:37 2015 +1300

Bug 1359109: Fail deleting long group names

Patch originally submitted by Daniel Parejo in bug report

Change-Id: I33d3d9c6ff12c69ef871de47fe15524659ceba36
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9) on 2015-02-17
Changed in mahara:
status: In Progress → Fix Committed
Robert Lyon (robertl-9) on 2015-04-17
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers