-
Bug
-
Resolution: Fixed
-
Minor
-
2.2.2, 2.3.2, 2.4
-
MySQL
-
MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
-
MOODLE_22_STABLE, MOODLE_23_STABLE
-
w38_
MDL-32572_m24_authdbduplicates -
-
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.