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

Cannot create new user if private profile fields used

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • None
    • 3.4
    • None
    • MOODLE_34_STABLE
    • Hide

      That is becase profile_field_base->is_visible tryes to find user with id = -1.

      In /user/profile/lib.php - profile_field_base - is_visible()

      $context = $this->userid ? context_user::instance($this->userid) : context_system::instance();

      should be replaced with 

       $context = $this->userid && ($this->userid != -1) ? context_user::instance($this->userid) : context_system::instance();

       

      Show
      That is becase profile_field_base->is_visible tryes to find user with id = -1. In /user/profile/lib.php - profile_field_base - is_visible() $context = $this->userid ? context_user::instance($this->userid) : context_system::instance(); should be replaced with   $context = $this->userid && ($this->userid != -1) ? context_user::instance($this->userid) : context_system::instance();  
    • Hide
      1. Login as admin.
      2. Create custom porfile text field, eg. job. 
      3. Navigate to adding new user. It should be /user/editadvanced.php?id=-1
      4. It shows error: 
         

      invalid user

      Debug info: SELECT id FROM {user} WHERE id = ? AND deleted = ?
      [array (
      0 => -1,
      1 => 0,
      )]
      Error code: invaliduser
      Stack trace: * line 1546 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown

      • line 1522 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
      • line 6015 of /lib/accesslib.php: call to moodle_database->get_record()
      • line 416 of /user/profile/lib.php: call to context_user::instance()
      • line 578 of /user/profile/lib.php: call to profile_field_base->is_visible()
      • line 149 of /user/editadvanced_form.php: call to profile_definition()
      • line 204 of /lib/formslib.php: call to user_editadvanced_form->definition()
      • line 155 of /user/editadvanced.php: call to moodleform->__construct()

       

      Show
      Login as admin. Create custom porfile text field, eg. job.  Navigate to adding new user. It should be /user/editadvanced.php?id=-1 It shows error:    invalid user Debug info:  SELECT id FROM {user} WHERE id = ? AND deleted = ? [array ( 0 => -1, 1 => 0, )] Error code: invaliduser Stack trace: * line 1546 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown line 1522 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select() line 6015 of /lib/accesslib.php: call to moodle_database->get_record() line 416 of /user/profile/lib.php: call to context_user::instance() line 578 of /user/profile/lib.php: call to profile_field_base->is_visible() line 149 of /user/editadvanced_form.php: call to profile_definition() line 204 of /lib/formslib.php: call to user_editadvanced_form->definition() line 155 of /user/editadvanced.php: call to moodleform->__construct()  

      Custom profile fields sybsystem incorrectly works with user id=-1, which is used, when creating new user.

            Unassigned Unassigned
            vadimon Vadim Dvorovenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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