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

External DB Auth: Suspends or Deleted Every User Bug

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 3.0.7, 3.1, 3.1.3
    • Fix Version/s: 3.0.8, 3.1.4
    • Component/s: Authentication
    • Labels:
    • Testing Instructions:
      Hide
      1. Use an external database with over 10,000 users (at the very least 10,010 so when you delete some it's still over 10,000)
        • for i in `seq 1 15000`; do echo "INSERT INTO yourtablename SET (username, firstname, lastname) VALUES ('user$i','User','$i')='user$i'" | mysql -uDBUSERNAME -pDBPASSWORD yourdatabasename; done
      2. Enable auth/db
      3. Configure the plugin to match you external database configs
      4. Ensure that delete is selected in "User Account Synchronisation".
      5. Run the syncronization via cron or CLI
      6. Remove some of your users in external database
      7. Run the synchronization via cron
      8. See that the missing users have now been removed (flagged with deleted=1 - but the other users are still there deleted=0.
        • Check your mdl_users table.
      Show
      Use an external database with over 10,000 users (at the very least 10,010 so when you delete some it's still over 10,000) for i in `seq 1 15000`; do echo "INSERT INTO yourtablename SET (username, firstname, lastname) VALUES ('user$i','User','$i')='user$i'" | mysql -uDBUSERNAME -pDBPASSWORD yourdatabasename; done Enable auth/db Configure the plugin to match you external database configs Ensure that delete is selected in "User Account Synchronisation". Run the syncronization via cron or CLI Remove some of your users in external database Run the synchronization via cron See that the missing users have now been removed (flagged with deleted=1 - but the other users are still there deleted=0 . Check your mdl_users table.
    • Workaround:
      Hide

      Add several 0's to line 307 in /auth/db/auth.php in the meantime.

      Show
      Add several 0's to line 307 in /auth/db/auth.php in the meantime.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-57193-master-notest

      Description

      On line 307 in /auth/db/auth.php We chunk the users up into groups of 10,000. Apparently to stop some databases from crashing.

      The issue is if you have remove users setup (suspend or delete) it will catch every user if you have more than 10,000 users...

      If there are 11,000 users it will get the first 10,000 and say "if the user in moodle isn't in this list add them to the remove user list" - there go the 1,000 users who should be left in the system. Then on the second loop it will grab the last 1,000 users and say "if the users in the db are not in this list remove them" - obviously the 1,000 users in the list got deleted in the previous loop and the ones that were found in the first pass were deleted in the second pass...

      For people with this issue the first thing to do immediately is change 10000 on line 307 to a number far higher than the number of users you currently have, until this is fixed.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Jan/17