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

Upload of Users with Custom Profile Menu fields may fail

    Details

    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide
      1. Log in as admin
      2. Create custom profile field "menu" of type menu. Options "one two three four five" (Site administration -> Users -> Accounts -> User profile fields)
      3. Try uploading attached file (Site administration -> Users -> Accounts -> Upload users)
      4. You should not see any error and two new users should be uploaded, check there profile and make sure menu has same option as csv file
      5. Now edit upload file and change menu entries to "4" and "2"
      6. Try upload and you should not any way to upload file. Also, error should be visible in status.
      Show
      Log in as admin Create custom profile field "menu" of type menu. Options "one two three four five" (Site administration -> Users -> Accounts -> User profile fields) Try uploading attached file (Site administration -> Users -> Accounts -> Upload users) You should not see any error and two new users should be uploaded, check there profile and make sure menu has same option as csv file Now edit upload file and change menu entries to "4" and "2" Try upload and you should not any way to upload file. Also, error should be visible in status.
    • Workaround:
      Hide

      Create Custom Profile yearlevel as text field

      Show
      Create Custom Profile yearlevel as text field
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull Master Branch:
      wip-mdl-31654

      Description

      Uploading users that have a column for a Custom Profile field which is a menu may fail because the data from the CSV is directly treated as a key in the Menu Class.

      This means if you have user_profile_yearlevel = 9, it will return the value for key 9 or blank in custom profile field yearlevel which may or may not exist. If it did exist it could return the wrong value to be assigned to the yearlevel.

      Reproduction steps:

      1. Create custom profile of type menu.
      2. Assign various values to the menu.
      3. Create a csv to upload a value to the menu.
      4. Update existing users and Existing user details from the file will work.

      When the csv is processed you will see this error :-

      Error writing to database
      
      More information about this error
      
      Debug info: ERROR: null value in column "data" violates not-null constraint
      UPDATE mdl_user_info_data SET userid = $1,fieldid = $2,data = $3 WHERE id=$4
      [array (
      'userid' => '80',
      'fieldid' => '4',
      'data' => NULL,
      0 => '384',
      )]
      Stack trace:
      line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 936 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 976 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->update_record_raw()
      line 118 of /user/profile/lib.php: call to pgsql_native_moodle_database->update_record()
      line 427 of /user/profile/lib.php: call to profile_field_base->edit_save_data()
      line 572 of /admin/uploaduser.php: call to profile_save_data()
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  5 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    25/Jun/12