learnweb / moodle-mod_ratingallocate

:pray: "Fair allocation" moodle activity
https://moodle.org/plugins/view/mod_ratingallocate
20 stars 29 forks source link

Bug: Transactions already disposed #306

Open PhMemmel opened 1 month ago

PhMemmel commented 1 month ago
Debug-Info:  Transactions already disposed
Error code: dmltransactionexception

Stack trace: 
line 103 of /lib/dml/moodle_transaction.php: dml_transaction_exception thrown
line 1969 of /mod/ratingallocate/locallib.php: call to moodle_transaction->rollback()
line 382 of /mod/ratingallocate/locallib.php: call to ratingallocate->save_ratings_to_db()
line 1262 of /mod/ratingallocate/locallib.php: call to ratingallocate->process_action_give_rating()
line 59 of /mod/ratingallocate/view.php: call to ratingallocate->handle_view()

To reproduce:

Reason is the line $completion->update_state($this->coursemodule, COMPLETION_UNKNOWN, $userid); which throws an exception here: https://github.com/moodle/moodle/blob/30692df8495bd16fc579f4c448bb322ece29cf84/lib/completionlib.php#L649

I'm not too deep into the completion code so I cannot really see what exactly is the issue with the completion here unless investing a lot of time I currently unfortunately do not have.

But besides that I feel like the transaction handling should also be improved: Exceptions being caused after the transaction has been commited must not trigger the rollback.

Tested with latest master on latest vanilla main. Issue at least exists also since de61f8db.

dlmsr commented 1 month ago

Thanks for the report. We will have a look :)