Affects Version/s: 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.7
Fix Version/s: 1.9
Affected Branches:MOODLE_15_STABLE, MOODLE_16_STABLE, MOODLE_17_STABLE
Users having special characters in some external locked fields (e.g. O'Brien for lastname) cannot update their profile.
They get the error message:
Could not update the user record ([user id])
because of database error:
You have an error in your SQL syntax; check the manual that corresponds to your (My)SQL server version for the right syntax to use near...
Replacing line 160 in user/edit.php
$usernew->$field = $user->$field;
$usernew->$field = addslashes(clean_text(stripslashes(trim($user->$field)), FORMAT_MOODLE));
solves the problem.
As it was suggested in old tracker, bug #4073.
Note that a (poor) workaround is to update the user profile as Moodle Admin because he can override the locked fields.