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

Redundant update query in lib/moodlelib: update_internal_user_password()

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.9, 2.0
    • Fix Version/s: 2.0
    • Component/s: Authentication
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      The following patch fixes a redundant update query that runs every time users log in.

      The patch is also relevant in HEAD.

      Updates to the user table can block if there is a transaction holding locks on those rows, eg. the auth_ldap_sync_users script could have updated the row inside its transaction. In this case the login would block until the transaction commits.

      diff --git a/lib/moodlelib.php b/lib/moodlelib.php
      index 6ffae69..7f7561c 100644
      — a/lib/moodlelib.php
      +++ b/lib/moodlelib.php
      @@ -3388,7 +3388,9 @@ function update_internal_user_password(&$user, $password)

      { $hashedpassword = hash_internal_user_password($password); }
      • return set_field('user', 'password', $hashedpassword, 'id', $user->id);
        + if ($user->password != $hashedpassword) { + return set_field('user', 'password', $hashedpassword, 'id', $user->id); + }

        }

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            ashleyholman Ashley Holman
            Tester:
            Nobody
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              24/Nov/10