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

DB authentication does not update profile fields if empty

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.4
    • Fix Version/s: None
    • Component/s: Authentication
    • Labels:
    • Testing Instructions:
      Hide

      Create an External Database to use with auth_db.

      Set up at least 1 Profile Field / User Info Field.

      Create a user in the external database with NO value in the remote user info field.

      Add a value in the external database remote user info field.

      Run sync again.

       

      Result: The new value will now appear in the users profile.

      Show
      Create an External Database to use with auth_db. Set up at least 1 Profile Field / User Info Field. Create a user in the external database with NO value in the remote user info field. Add a value in the external database remote user info field. Run sync again.   Result: The new value will now appear in the users profile.
    • Affected Branches:
      MOODLE_34_STABLE

      Description

      Example of issue:

      If Joe Bloggs has a UserInfoField of Department with the value: Computing

      and the external DB changes the department to Music it updates correctly.

       

      However if Joe Bloggs was created with an empty Department field.

      When the external DB changes the department to Music it does not update.

       

      Code at fault: 

      if (isset($user->{$key}) and $user->{$key} != $value) {
      

      Should not have the isset part as if the value is not set yet the new value needs to be set.

       

       

      Proposed solution (two options) 

      if ($user->{$key} != $value) {

      OR:

      if ((isset($user->{$key}) AND $user->{$key} != $value) OR (!isset($user->{$key}) AND isset($value)) {
      

       For Simplicity I would recommend the first option, but either would work.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated: