Can not add groups via CSV when shortname is not relied on displayname

Bug #1613503 reported by Son Nguyen
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Robert Lyon

Bug Description

version: master(16.10)

I got the following message when adding groups via CSV

Mahara: Site unavailable
Something in the way you're interacting with Mahara is causing an error.
Details if any, follow:

group_create: The supplied shortname 'gc' is already taken. This shortname 'groupc' is available.

The content of my CSV file:
shortname,displayname,roles
"gc","Group C","standard"

I have to change the shortname to 'groupc' to make it work.
Is it the new behaviour?

Revision history for this message
Robert Lyon (robertl-9) wrote :

in lib/group.php line 357

    if (!empty($data['shortname'])) {
        // make sure it is unique and is correct length
        $shortname = group_generate_shortname($data['name']);
        // If we want to retain the supplied shortname we need to make sure it can be done
        if (!empty($data['retainshortname'])) {
            if ($shortname != $data['shortname']) {

The
   $shortname = group_generate_shortname($data['name']);
should be
   $shortname = group_generate_shortname($data['shortname']);

So that we compare supplied shortname with valid one - which should be the same unless the supplied string contains invalid chars or the valid one is different because the supplied one is taken

Revision history for this message
Son Nguyen (ngson2000) wrote :

It works fine now. Thank for your explanation.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/6844

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/6844
Committed: https://git.mahara.org/mahara/mahara/commit/258273c4209411d51814bd39f4251ea144e843eb
Submitter: Son Nguyen (<email address hidden>)
Branch: master

commit 258273c4209411d51814bd39f4251ea144e843eb
Author: Robert Lyon <email address hidden>
Date: Tue Aug 16 15:00:14 2016 +1200

Bug 1613503: Validate the shortname generated from provided shortname in CSV

not from displayname

behatnotneeded

Change-Id: If7134f6b97031fc848684b053795a02504b27316

Son Nguyen (ngson2000)
Changed in mahara:
status: New → Fix Committed
assignee: nobody → Robert Lyon (robertl-9)
importance: Undecided → High
Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.