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

"profile_field_menu" fields fail during upload of users from csv

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • 1.9.2
    • Administration
    • MOODLE_19_STABLE

      When uploading users from a csv file a menu-type custom user profile does not get the values inserted.

      For example I have a user profile field with a shortname of studionumber that is a menu type field. The options are:

      1234
      2341
      3421

      In the csv I have:

      firstname, lastname, username, email, profile_field_studionumber
      testfirst, testlast, testuser, testuser@localhost.com, 2341

      When I upload the user, the user gets added, but the custom menu field does not take the supplied value.

      I get this error:

      Column 'data' cannot be null

      INSERT INTO mdl_user_info_data ( USERID, FIELDID, DATA ) VALUES ( 23, 3, null )

      • line 1554 of lib\dmllib.php: call to debugging()
      • line 102 of user\profile\lib.php: call to insert_record()
      • line 355 of user\profile\lib.php: call to profile_field_base->edit_save_data()
      • line 548 of admin\uploaduser.php: call to profile_save_data()

      The problem is this:

      profile_field_base->edit_save_data() calls profile_field_menu->edit_save_data_preprocess(). This function expects the key of the options array (which is what it is when it is called from editadvanced.php and other forms). However, since the csv file likely (and sensibly) contains a value and not a key edit_save_data_preprocess gets the value as a parameter instead of the key and returns NULL as a result.

      I tried a quick hack as a solution and have attached the svn diff of the potential fix (it works, but may not be the most elegant solution).

      Hope this helps.

            stronk7 Eloy Lafuente (stronk7)
            sbc24 Sam Chaffee
            Votes:
            7 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

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