Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-27608

Potential performance issue for profile fields

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • None
    • 2.0.3
    • Performance
    • MOODLE_20_STABLE

      In /user/profile/lib.php

      function profile_display_fields($userid) {
          global $CFG, $USER, $DB;
       
          if ($categories = $DB->get_records('user_info_category', null, 'sortorder ASC')) {
              foreach ($categories as $category) {
                  if ($fields = $DB->get_records('user_info_field', array('categoryid'=>$category->id), 'sortorder ASC')) {
                      foreach ($fields as $field) {
                          require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
                          $newfield = 'profile_field_'.$field->datatype;
                          $formfield = new $newfield($field->id, $userid);
                          if ($formfield->is_visible() and !$formfield->is_empty()) {
                              print_row(format_string($formfield->field->name.':'), $formfield->display_data());
                          }
                      }
                  }
              }
          }
      }

      "There is no need to fetch the categories - you fetch all categories and then fetch all fields for each category = all fields that have a valid category. You could either join to the category table of if the category had to be valid (NOT NULL) then selecting all fields is fine." - Sam in MDL-26774 about the get_users_by_id that was copied from this above piece of code

            Unassigned Unassigned
            jerome Jérôme Mouneyrac
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.