diff --git a/lib/classes/message/manager.php b/lib/classes/message/manager.php
index cf0a602230f..c05e14d8171 100644
--- a/lib/classes/message/manager.php
+++ b/lib/classes/message/manager.php
@@ -169,15 +169,9 @@ class manager {
)->trigger();
}
- // If messaging is disabled and they previously had forum notifications handled by the popup processor
- // or any processor that puts a row in message_working then the notification will remain forever
- // unread. To prevent this mark the message read if messaging is disabled.
- if (empty($CFG->messaging) && $eventdata->notification) {
- \core_message\api::mark_notification_as_read($savemessage);
- }
-
- // If there is no more processors that want to process this we can mark the message as read.
- if ($DB->count_records('message_working', array('unreadmessageid' => $savemessage->id)) == 0) {
+ if (empty($CFG->messaging)) {
+ // If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
+ // The same goes if the messaging is completely disabled.
if ($eventdata->notification) {
$savemessage->timeread = null;
\core_message\api::mark_notification_as_read($savemessage);
diff --git a/lib/db/install.xml b/lib/db/install.xml
index ffc0d42c33b..6cdb5fc8f31 100644
--- a/lib/db/install.xml
+++ b/lib/db/install.xml
@@ -2434,19 +2434,6 @@
-
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 5da6ff7437e..86bec924ff5 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -2151,5 +2151,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2018032200.04);
}
+ if ($oldversion < 2018032200.05) {
+ // Drop table that is no longer needed.
+ $table = new xmldb_table('message_working');
+ if ($dbman->table_exists($table)) {
+ $dbman->drop_table($table);
+ }
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2018032200.05);
+ }
+
return true;
}
diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php
index 01523c90c30..ccb08415547 100644
--- a/lib/deprecatedlib.php
+++ b/lib/deprecatedlib.php
@@ -6359,19 +6359,12 @@ function message_mark_message_read($message, $timeread, $messageworkingempty=fal
debugging('message_mark_message_read() is deprecated, please use \core_message\api::mark_message_as_read()
or \core_message\api::mark_notification_as_read().', DEBUG_DEVELOPER);
- global $DB;
-
if (!empty($message->notification)) {
\core_message\api::mark_notification_as_read($message, $timeread);
} else {
\core_message\api::mark_message_as_read($message->useridto, $message, $timeread);
}
- // If any processors have pending actions abort them.
- if (!$messageworkingempty) {
- $DB->delete_records('message_working', array('unreadmessageid' => $message->id));
- }
-
return $message->id;
}
diff --git a/lib/tests/messagelib_test.php b/lib/tests/messagelib_test.php
index 5f1c2c7bb16..ed6e8ab14fa 100644
--- a/lib/tests/messagelib_test.php
+++ b/lib/tests/messagelib_test.php
@@ -575,7 +575,6 @@ class core_messagelib_testcase extends advanced_testcase {
$this->assertCount(1, $emails);
$email = reset($emails);
$savedmessage = $DB->get_record('messages', array('id' => $messageid), '*', MUST_EXIST);
- $working = $DB->get_record('message_working', array('unreadmessageid' => $messageid), '*', MUST_EXIST);
$this->assertSame($user1->email, $email->from);
$this->assertSame($user2->email, $email->to);
$this->assertSame($message->subject, $email->subject);
@@ -609,7 +608,6 @@ class core_messagelib_testcase extends advanced_testcase {
$emails = $sink->get_messages();
$this->assertCount(0, $emails);
$savedmessage = $DB->get_record('messages', array('id' => $messageid), '*', MUST_EXIST);
- $working = $DB->get_record('message_working', array('unreadmessageid' => $messageid), '*', MUST_EXIST);
$sink->clear();
$this->assertFalse($DB->record_exists('message_user_actions', array()));
$DB->delete_records('messages', array());
diff --git a/message/output/popup/message_output_popup.php b/message/output/popup/message_output_popup.php
index 33065ee4c13..dde8b2c9e85 100644
--- a/message/output/popup/message_output_popup.php
+++ b/message/output/popup/message_output_popup.php
@@ -41,26 +41,6 @@ class message_output_popup extends message_output {
* @return true if ok, false if error
*/
public function send_message($eventdata) {
- global $DB;
-
- //hold onto the popup processor id because /admin/cron.php sends a lot of messages at once
- static $processorid = null;
-
- //prevent users from getting popup notifications of messages to themselves (happens with forum notifications)
- if ($eventdata->userfrom->id != $eventdata->userto->id) {
- if (empty($processorid)) {
- $processor = $DB->get_record('message_processors', array('name'=>'popup'));
- $processorid = $processor->id;
- }
- $procmessage = new stdClass();
- $procmessage->unreadmessageid = $eventdata->savedmessageid;
- $procmessage->processorid = $processorid;
- $procmessage->notification = $eventdata->notification;
-
- //save this message for later delivery
- $DB->insert_record('message_working', $procmessage);
- }
-
return true;
}
diff --git a/version.php b/version.php
index cdca8f9f91e..b8e0dca8474 100644
--- a/version.php
+++ b/version.php
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2018032200.04; // YYYYMMDD = weekly release date of this DEV branch.
+$version = 2018032200.05; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.