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

fatal error when viewing user profile when not logged in under some circumstances



      Problem arises because of the following

      $USER->id is 0, set on line 292 of lib/sessionlib.php (check_user_initialised)

      executes last statement of this if statement on line 262 of user/profile.php
      if ($currentuser
      or $user->maildisplay == 1
      or has_capability('moodle/course:useremail', $context)
      or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER))) {

      which ends up testing !empty($user2->id) on line 268 of lib/enrollib.php (enrol_get_shared_courses)
      where $user2 === $USER

      The empty function (http://php.net/manual/en/function.empty.php) returns true when the variable is 0. This is not the wanted behaviour.

      A fix would be to change this to use isset instead of !empty

      A stack trace is below, a patch is attached

      Coding error detected, it must be fixed by a programmer: PHP catchable fatal error

      More information about this error

      Debug info: Object of class stdClass could not be converted to string
      Stack trace:
      line 359 of /lib/setuplib.php: coding_exception thrown
      line ? of unknownfile: call to default_error_handler()
      line 636 of /lib/dml/pgsql_native_moodle_database.php: call to pg_query_params()
      line 1587 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_recordset_sql()
      line 297 of /lib/enrollib.php: call to moodle_database->record_exists_sql()
      line 237 of /lib/enrollib.php: call to enrol_get_shared_courses()
      line 267 of /user/profile.php: call to enrol_sharing_course()

        Gliffy Diagrams




              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created:
                  Fix Release Date: