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

Potential performance for retrieving course listing in the profile page

XMLWordPrintable

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

      in /user/profile.php

      if (!isset($hiddenfields['mycourses'])) {
          if ($mycourses = enrol_get_users_courses($user->id, true, NULL, 'visible DESC,sortorder ASC')) {
              $shown=0;
              $courselisting = '';
              foreach ($mycourses as $mycourse) {
                  if ($mycourse->category) {
                      $class = '';
                      if ($mycourse->visible == 0) {
                          $ccontext = get_context_instance(CONTEXT_COURSE, $mycourse->id);
                          if (!has_capability('moodle/course:viewhiddencourses', $ccontext)) {
                              continue;
                          }
                          $class = 'class="dimmed"';
                      }
                      $courselisting .= "<a href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&amp;course={$mycourse->id}\" $class >" . format_string($mycourse->fullname) . "</a>, ";
                  }
                  $shown++;
                  if($shown==20) {
                      $courselisting.= "...";
                      break;
                  }
              }
              print_row(get_string('courseprofiles').':', rtrim($courselisting,', '));
          }
      }

      "What is the purpose of the $mycourse->category check? Category should always be set." - am in MDL-26774 about the get_users_by_id that was copied from this above piece of code

      if MDL-26774 come to be resolved before this issue, then the error will probably be there too and you need to fix it too !

            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.