MDL-58050 message: Commit the transaction before the early return
If there was no conversation found and the method returned early, the active transaction was not marked as committable and the error was reported by the request shutdown handler. Attaching a unit test for the case just because it did not seem to be covered. I was trying to reproduce the thrown error in the unit test but it can't be used in this case. The shutdown handler puts the warning directly into the error_log and it is not guaranteed where such messages go (depending on the PHP configuration). And we do not even raise it during the unit test execution (presumably due to noise it would produce) anyway.
This commit is contained in:
@@ -314,6 +314,7 @@ class api {
|
||||
|
||||
// This user has no conversations so we can return early here.
|
||||
if (empty($conversationrecords)) {
|
||||
$transaction->allow_commit();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@@ -333,6 +333,9 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
|
||||
// The person doing the search.
|
||||
$this->setUser($user1);
|
||||
|
||||
// No conversations yet.
|
||||
$this->assertEquals([], \core_message\api::get_conversations($user1->id));
|
||||
|
||||
// Send some messages back and forth, have some different conversations with different users.
|
||||
$time = 1;
|
||||
$this->send_fake_message($user1, $user2, 'Yo!', 0, $time + 1);
|
||||
|
||||
Reference in New Issue
Block a user