MDL-36941 core: removed 'message_working' table
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -2434,19 +2434,6 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="message_working" COMMENT="Lists all the messages and processors that need to be processed">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" COMMENT="id of the table, please edit me"/>
|
||||
<FIELD NAME="unreadmessageid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="message that still needs some processing (on message table)"/>
|
||||
<FIELD NAME="processorid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The processor with processes the message"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="unreadmessageid_idx" UNIQUE="false" FIELDS="unreadmessageid" COMMENT="Index on unreadmessage id"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="files" COMMENT="description of files, content is stored in sha1 file pool">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user