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
    • Rank:
      38227

      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()
      
      1. user.csv
        0.2 kB
        Michael de Raadt
      2. user.csv
        0.2 kB
        Rajesh Taneja

        Issue Links

          Activity

          Tim Lock created issue -
          Tim Lock made changes -
          Field Original Value New Value
          Priority Minor [ 4 ] Major [ 3 ]
          Labels partner
          Michael de Raadt made changes -
          Fix Version/s STABLE Sprint 18 [ 11650 ]
          Testing Instructions Create custom profile of type menu.
          Assign various values to the menu.
          Create a csv to upload a value to the menu.
           - 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()

          Description When 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.
          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:*
          # Create custom profile of type menu.
          # Assign various values to the menu.
          # Create a csv to upload a value to the menu.
          # Update existing users and Existing user details from the file will work.

          When the csv is processed you will see this error :-
          {noformat}
          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()
          {noformat}
          Labels partner partner triaged
          Michael de Raadt made changes -
          Labels partner triaged partner patch triaged
          Rajesh Taneja made changes -
          Status Open [ 1 ] Development in progress [ 3 ]
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Rajesh Taneja made changes -
          Peer reviewer rwijaya
          Rajesh Taneja made changes -
          Testing Instructions # 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
          Rajesh Taneja made changes -
          Attachment user.csv [ 27089 ]
          Rajesh Taneja made changes -
          Labels partner patch triaged docs_required partner patch triaged
          Rossiani Wijaya made changes -
          Original Estimate 0 minutes [ 0 ]
          Remaining Estimate 0 minutes [ 0 ]
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Rossiani Wijaya made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Rossiani Wijaya made changes -
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Rossiani Wijaya made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Rossiani Wijaya made changes -
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Rossiani Wijaya made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Rajesh Taneja made changes -
          Testing Instructions # 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
          # 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.
          Pull 2.1 Branch wip-mdl-31654-m21
          Rajesh Taneja made changes -
          Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
          Sam Hemelryk made changes -
          Currently in integration Yes [ 10041 ]
          Aparup Banerjee made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator nebgor
          Aparup Banerjee made changes -
          Status Integration review in progress [ 10004 ] Reopened [ 4 ]
          Rajesh Taneja made changes -
          Labels docs_required partner patch triaged docs_required partner patch triaged ui_change
          Sam Hemelryk made changes -
          Currently in integration Yes [ 10041 ]
          Rajesh Taneja made changes -
          Status Reopened [ 4 ] Waiting for integration review [ 10010 ]
          Sam Hemelryk made changes -
          Currently in integration Yes [ 10041 ]
          Aparup Banerjee made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Aparup Banerjee made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          Affects Version/s 2.2.2 [ 11552 ]
          Affects Version/s 2.1.5 [ 11553 ]
          Affects Version/s 2.0.8 [ 11554 ]
          Affects Version/s 2.0.7 [ 11451 ]
          Affects Version/s 2.1.4 [ 11452 ]
          Affects Version/s 2.2.1 [ 11456 ]
          Fix Version/s 2.3 [ 10657 ]
          Michael de Raadt made changes -
          Tester salvetore
          Michael de Raadt made changes -
          Attachment user.csv [ 27703 ]
          Michael de Raadt made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Michael de Raadt made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          Eloy Lafuente (stronk7) made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes [ 10041 ]
          Integration date 29/Mar/12
          Michael de Raadt made changes -
          Link This issue will help resolve MDL-26653 [ MDL-26653 ]
          Helen Foster made changes -
          Labels docs_required partner patch triaged ui_change partner patch triaged ui_change
          Michael de Raadt made changes -
          Link This issue caused a regression MDL-41744 [ MDL-41744 ]
          Eloy Lafuente (stronk7) made changes -
          Fix Version/s STABLE Sprint 18 [ 11650 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved: