Restoring Course with existing users.

Restoring Course with existing users.

by Chetan Madaan -
Number of replies: 1

Hi,

We are trying to merge two moodle installations we have by exporting/importing courses one one into the second and we do want to bring in users and their information.

Enabling debug and running an import shows the following error:

Class coursecat is now alias to autoloaded class core_course_category, course_in_list is an alias to core_course_list_element. Class coursecat_sortable_records is deprecated without replacement. Do not include coursecatlib.php
  • line 31 of /lib/coursecatlib.php: call to debugging()
  • line 29 of /theme/bcu/renderers.php: call to require_once()
  • line 771 of /lib/outputlib.php: call to include_once()
  • line 679 of /lib/outputlib.php: call to theme_config->__construct()
  • line 7400 of /lib/moodlelib.php: call to theme_config::load()
  • line 1158 of /backup/util/dbops/restore_dbops.class.php: call to get_list_of_themes()
  • line 1144 of /backup/moodle2/restore_stepslib.php: call to restore_dbops::create_included_users()
  • line 34 of /backup/util/plan/restore_execution_step.class.php: call to restore_create_included_users->define_execution()
  • line 181 of /backup/util/plan/base_task.class.php: call to restore_execution_step->execute()
  • line 178 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
  • line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
  • line 377 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
  • line 219 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
  • line 143 of /backup/restore.php: call to restore_ui->execute()
×Debug info: Duplicate entry '0-kasha' for key 'mdl_user_mneuse_uix'
INSERT INTO mdl_user (username,idnumber,email,icq,skype,yahoo,aim,msn,phone1,phone2,institution,department,address,city,country,lastip,picture,url,description,descriptionformat,imagealt,auth,firstnamephonetic,lastnamephonetic,middlename,alternatename,firstname,lastname,confirmed,policyagreed,deleted,lang,theme,timezone,firstaccess,lastaccess,lastlogin,currentlogin,mailformat,maildigest,maildisplay,autosubscribe,trackforums,timecreated,timemodified,trustbitmask,password) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
[array (
0 => 'kasha',
1 => '',
2 => 'someone@oursite.com',
3 => '',
4 => '',
5 => '',
6 => '',
7 => '',
8 => '',
9 => '',
10 => '',
11 => '',
12 => '',
13 => 'name',
14 => 'US',
15 => '8.8.8.8',
16 => '4589',
17 => '',
18 => '',
19 => '1',
20 => '',
21 => 'manual',
22 => '',
23 => '',
24 => '',
25 => '',
26 => 'First',
27 => 'Last',
28 => '1',
29 => 0,
30 => '0',
31 => 'en',
32 => '',
33 => '',
34 => '1467589437',
35 => '1619184719',
36 => '1619113879',
37 => '1619183891',
38 => '1',
39 => '0',
40 => '1',
41 => '1',
42 => '0',
43 => 1619933490,
44 => '1586774852',
45 => '0',
46 => 'restored',
)]
Error code: dmlwriteexception
×Stack trace:
  • line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 1331 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1377 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 1245 of /backup/util/dbops/restore_dbops.class.php: call to mysqli_native_moodle_database->insert_record()
  • line 1144 of /backup/moodle2/restore_stepslib.php: call to restore_dbops::create_included_users()
  • line 34 of /backup/util/plan/restore_execution_step.class.php: call to restore_create_included_users->define_execution()
  • line 181 of /backup/util/plan/base_task.class.php: call to restore_execution_step->execute()
  • line 178 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
  • line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
  • line 377 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
  • line 219 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
  • line 143 of /backup/restore.php: call to restore_ui->execute()
Error Paste end:

My knowledge of mysql tell me that since the user with the same username already exists, it wouldn't continue but at the same time I see the following https://docs.moodle.org/37/en/MySQL_full_unicode_support url recommended as a possible fix.

Can anyone shed some light here?

Thanks,

Chetan

Average of ratings: -
In reply to Chetan Madaan

Re: Restoring Course with existing users.

by Ken Task -
Picture of Particularly helpful Moodlers

"Class coursecat_sortable_records is deprecated without replacement"

So we are trying to 'merge' courses from 2 different moodles ... what are the versions of moodle involved?   Guessing older moodle version > newer moodle version? or is it the other way round?

Error has been reported before and back then, the advice suggested to fix follows (summation/translated below):

Compare what you have in config.php DB array (especially collation) with the true tables collation ... use scripts in moodlecode/admin/cli/ for mysql ... run them all to verify tables and columns are all the same.

'SoS', Ken