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

Deleting a user causes incorrect 'usernamelowercase' error with user_update_user function

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Duplicate
    • Affects Version/s: 2.6.1, 2.7.3, 2.8.1
    • Fix Version/s: None
    • Component/s: Authentication
    • Labels:
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE

      Description

      NOTE: This only affects the deletion of users where the email field is empty - e.g. in cases where the account was created via an import.

      Line 109 of user/lib.php

      if ($user->username !== core_text::strtolower($user->username)

      The code above is comparing values AND types.
      When I get the error with 'usernamelowercase' it isn't because the strings don't match, its because $user->username is a double and the value returned by core_text::strtolower($user->username) is a string.

      There are many possible fixes for this

      1) remove an equals sign from line 109 of user/lib.php

      if ($user->username != core_text::strtolower($user->username)

      2) force a string value on the username on line 109 of user/lib.php

      if (strval($user->username) !== core_text::strtolower($user->username)

      3) force a string value on the username on line 4249 of moodlelib.php

      $updateuser->username = strval($delname);

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: