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

Cannot create any new User Account via database synchronization if user with different auth type already present

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.3.2, 2.4
    • Fix Version/s: 2.2.6, 2.3.3
    • Component/s: Authentication
    • Labels:
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      1/ set up external user table with several accounts which include user with username 'admin' (collision with normal admin)
      2/ set up auth_db
      3/ execute cli sync in auth_db in verbose mode
      4/ verify in master you are told about admin username collision, in 22 and 23 make sure general insert error is displayed
      5/ try to log in as the new users
      6/ switch to internal passwords for auth_db and manually set new passwords for the users
      7/ try to login with the new passwords

      Show
      1/ set up external user table with several accounts which include user with username 'admin' (collision with normal admin) 2/ set up auth_db 3/ execute cli sync in auth_db in verbose mode 4/ verify in master you are told about admin username collision, in 22 and 23 make sure general insert error is displayed 5/ try to log in as the new users 6/ switch to internal passwords for auth_db and manually set new passwords for the users 7/ try to login with the new passwords
    • Workaround:
      Hide

      Remove/change colliding usernames in other auth plugins or change auth type to 'db' for existing users.

      Show
      Remove/change colliding usernames in other auth plugins or change auth type to 'db' for existing users.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w38_MDL-32572_m24_authdbduplicates

      Description

      Hello,

      This is about creating using account through database synchronization

      I have this working on 1.9.14+ but for 2.2.2+, it's giving me an error

      sudo -u apache /usr/bin/php /var/www/html/moodle2test/auth/db/cli/sync_users.php -v

      User entries to add: 146
      !!! Error writing to database !!!

      So I turned on debugging and got this ...
      -----------------

      User entries to add: 146
      !!! Error writing to database !!!
      !! Duplicate entry '5-000186727' for key 'mdl_user_mneuse_uix'
      INSERT INTO mdl_user (firstname,lastname,email,username,confirmed,auth,mnethostid,lang,timecreated,timemodified) VALUES(?,?,?,?,?,?,?,?,?,?)
      [array (
      0 => 'Kardassian',
      1 => 'Kim',
      2 => 'kim.kardassian@student.ourschool.com',
      3 => '000186727',
      4 => 1,
      5 => 'db',
      6 => '5',
      7 => 'en',
      8 => 1333141068,
      9 => 1333141068,
      )] !!
      !! Stack trace: * line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown

      • line 893 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      • line 935 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      • line 375 of /auth/db/auth.php: call to mysqli_native_moodle_database->insert_record()
      • line 91 of /auth/db/cli/sync_users.php: call to auth_plugin_db->sync_users()
        !!

      looks like the same as this bug recorded ...

      http://tracker.moodle.org/browse/MDL-29267

      I figured out the cause... it works better in 1.9.x =)

      Everyday we have new users that we can insert into moodle taken from a delimited file which is inserted into a database for synchronization. At the end of the work day (Monday to Friday), we rename this file so it would create a new one. If not, new accounts will be appended to this text file.

      This is the cause of the problem.

      When we append new records, existing ones already exist from the previous day's synchronization. That is why we get this error.

      In version 1.9.x, we don't have this problem as it will just skip it...

      User entries to add: 62
      Error inserting user 000186727
      Error inserting user 000173269
      .....
      Error inserting user 000331042
      Inserted user 000331043 id 60992
      Inserted user 000331044 id 60993
      Inserted user 000331045 id 60994
      Inserted user 000331046 id 60995
      ......

      Note how in 1.9.x it continues on and adds the new users at the end BUT NOT IN 2.2.2+.

      In version 2.2.2+, it stops at the first instance of the error and does not add any new ones.

      Is there a fix to this so it would like for 1.9.14+?

      Thank you.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  3 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    12/Nov/12