moodle-tool_mergeusers icon indicating copy to clipboard operation
moodle-tool_mergeusers copied to clipboard

Merge User account error

Open tifano opened this issue 4 years ago • 5 comments

Hi, Has anyone come across this issue? Spent hours but no luck.

  1. Choose users to merge / ► 2. Confirm users to merge / ► 3. Merging results and log

Merged «test1» (user ID = 1157) into «[email protected]» (user ID = 3087)

For further reference, these results are recorded in the log id 7. Some error occurred:

Exception thrown when merging: 'Error reading from database". You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-LAST USED} WHERE userid = '1157'' at line 1 Trace: #0 /home/otc/public_html/lib/dml/mysqli_native_moodle_database.php(1247): moodle_database->query_end(false) #1 /home/otc/public_html/admin/tool/mergeusers/lib/table/generictablemerger.php(297): mysqli_native_moodle_database->get_records_sql('SELECT id FROM ...') #2 /home/otc/public_html/admin/tool/mergeusers/lib/table/generictablemerger.php(73): GenericTableMerger->get_records_to_be_updated(Array, 'userid') #3 /home/otc/public_html/admin/tool/mergeusers/lib/mergeusertool.php(268): GenericTableMerger->merge(Array, Array, Array) #4 /home/otc/public_html/admin/tool/mergeusers/lib/mergeusertool.php(192): MergeUserTool->_merge('3087', '1157') #5 /home/otc/public_html/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('3087', '1157') #6 {main}

Started merging at Monday, 4 May 2020, 1:27 AM Merge took 2 seconds

Merge failed! Your database engine supports transactions. Therefore, the whole current transaction has been rolled back and no modification has been made to your database.

Here is the screenshot:

image

Thanks for your help

tifano avatar May 03 '20 15:05 tifano

Hi!

Thanks for your report.

This error usually happens when a table in the moodle database has no column id on it, which is mandatory in Moodle on any table.

This is similar to the situation in https://github.com/ndunand/moodle-tool_mergeusers/issues/173#issuecomment-617738111. Follow those instructions to let you merge users, without processing any table that has no id column.

Thanks for your time.

Keep us updated.

Regards!

jpahullo avatar May 04 '20 18:05 jpahullo

This make me feel that we should prevent merging database tables without idcolumn, and inform it on the Moodle web (either on the plugin settings and or the merging results).

jpahullo avatar May 04 '20 18:05 jpahullo

Thanks Jordi, will give it a go and update.

Cheers

On Tue, May 5, 2020 at 4:07 AM Jordi Pujol-Ahulló [email protected] wrote:

Hi!

Thanks for your report.

This error usually happens when a table in the moodle database has no column id on it, which is mandatory in Moodle on any table.

This is similar to the situation in #173 (comment) https://github.com/ndunand/moodle-tool_mergeusers/issues/173#issuecomment-617738111. Follow those instructions to let you merge users, without processing any table that has no id column.

Thanks for your time.

Keep us updated.

Regards!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ndunand/moodle-tool_mergeusers/issues/174#issuecomment-623618579, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADQHGWVJGTEBMKV4ARGEP33RP3757ANCNFSM4MYFQQSA .

tifano avatar May 05 '20 10:05 tifano

We should use this issue to improve the plugin to, automatically, prevent mergint database tables without id column. id columns is requisite in Moodle tables. Third party plugins or other kind of tables should be omitted from processing if they do not have an id column.

jpahullo avatar Jun 10 '21 22:06 jpahullo

I have added a message in regards to the temporary config.local.php fix not working here https://github.com/ndunand/moodle-tool_mergeusers/issues/173

but as for a more permanent fix would the ideal way just be to do a check using SQL if the table has an id column? Is that the route the would be performant and quickest turn around for a new release?

I guess you could not check the moodle specific tables as they are always expected to have id

pmonty avatar Jun 11 '21 05:06 pmonty