-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
3.11.15
-
None
-
MOODLE_311_STABLE
When are you creating custom user profile fields, shortname need to be unique, but it is available to store uniq shrotname with uper case fonts.
When are you using profile field api, then is shorntame used in parsing as field identification, in this parsing is shorname lowercased.
Then may occure issue which will trigger duplicate shortname and lot of other issued in dev.
1. Navigate to user/profile/index.php
2. Create new profile field
3. Select Text input field
4. Fill Short name (must be unique) with "externalatribute"
5. Fill Character limit to "255"
6. Save form
7. Create new profile field
8. Select Text input field
9. Fill Short name (must be unique) with "ExternalAtribute"
10. Fill Character limit to "255"
11. Save form
12. Go to admin/search.php?query=showuseridentity
13. Select both created fields as identity fields
14. Go to admin/user.php
It is show just one of selected fields, with bug:
Did you remember to make the first column something unique in your call to get_records? Duplicate value '2' found in column 'id'.
- line 1287 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
- line 544 of /lib/datalib.php: call to mysqli_native_moodle_database->get_records_sql()
- line 248 of /admin/user.php: call to get_users_listing()
public static function get_identity_fields(?{color}context $context, bool $allowcustom = true): array {
global $CFG; // Only users with permission get the extra fields. if ($context && !has_capability('moodle/site:viewuseridentity', $context)) {
return []; {color}}
// Split showuseridentity on comma (filter needed in case the showuseridentity is empty). $extra = array_filter(explode(',', $CFG->showuseridentity)); // If there are any custom fields, remove them if necessary (either if allowcustom is false, // or if the user doesn't have access to see them). foreach ($extra as $key => $field) {
if (preg_match(self::PROFILE_FIELD_REGEX, $field, $matches)) {
$allowed = false; if ($allowcustom) {
require_once($CFG->dirroot . '/user/profile/lib.php'); // Ensure the field exists (it may have been deleted since user identity was configured). $field = profile_get_custom_field_data_by_shortname($matches[1], false); if ($field !== null) {
$fieldinstance = profile_get_user_field($field>datatype, $field>id, 0, $field); $allowed = $fieldinstance->is_visible($context); {color}}
}
if (!$allowed) {
unset($extra[$key]); {color}}
}
}
// For standard user fields, access is controlled by the hiddenuserfields option and // some different capabilities. Check and remove these if the user can't access them. $hiddenfields = array_filter(explode(',', $CFG->hiddenuserfields)); $hiddenidentifiers = array_intersect($extra, $hiddenfields); if ($hiddenidentifiers) {
if (!$context) {
$canviewhiddenuserfields = true; {color}} else if ($context->get_course_context(false)) {
// We are somewhere inside a course. $canviewhiddenuserfields = has_capability('moodle/course:viewhiddenuserfields', $context); {color}} else {
// We are not inside a course. $canviewhiddenuserfields = has_capability('moodle/user:viewhiddendetails', $context); {color}}
if (!$canviewhiddenuserfields) {
// Remove hidden identifiers from the list. $extra = array_diff($extra, $hiddenidentifiers); {color}}
}
// Re-index the entries and return. $extra = array_values($extra); return array_map([core_text::class, 'strtolower'], $extra);
{color}}
Possible solution:
Force to write/store uniq lower case shortname for user profile field.
- duplicates
-
MDL-73461 Make custom user profile field shortnames case-insensitive
-
- Open
-