Commit f7bd4df3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix SQL error uploading CSV files with missing username (bug #936589)

When a user csv file with a missing username is uploaded, you get a
"Site unavailable" error instead of a helpful error message because
the validation function attempts to check for duplicates. The
duplicate username check should be skipped when the username is empty.

Change-Id: I59424d51c1b8ab72bbb4b14a33f4e55d2332e156
Signed-off-by: default avatarRichard Mansfield <>
parent 1c1aabe0
......@@ -334,6 +334,11 @@ function uploadcsv_validate(Pieform $form, $values) {
$remoteusers[$remoteuser] = true;
// If we didn't even get a username, we can't check for duplicates, so move on.
if (strlen($username) < 1) {
if (isset($usernames[strtolower($username)])) {
// Duplicate username within this file.
$csverrors->add($i, get_string('uploadcsverroruseralreadyexists', 'admin', $i, $username));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment