}
/**
- * Do the job.
+ * Do the job. Each message processor also gets the chance to perform it's own cleanup.
* Throw exceptions on errors (the job will be retried).
*/
public function execute() {
$timenow = time();
+ $processors = get_message_processors(true);
+
// Cleanup read and unread notifications.
if (!empty($CFG->messagingdeleteallnotificationsdelay)) {
$notificationdeletetime = $timenow - $CFG->messagingdeleteallnotificationsdelay;
+
+ /** @var \message_output $processor */
+ foreach (array_column($processors, 'object') as $processor) {
+ $processor->cleanup_all_notifications($notificationdeletetime);
+ }
+
$params = array('notificationdeletetime' => $notificationdeletetime);
$DB->delete_records_select('notifications', 'timecreated < :notificationdeletetime', $params);
}
// Cleanup read notifications.
if (!empty($CFG->messagingdeletereadnotificationsdelay)) {
$notificationdeletetime = $timenow - $CFG->messagingdeletereadnotificationsdelay;
+
+ /** @var \message_output $processor */
+ foreach (array_column($processors, 'object') as $processor) {
+ $processor->cleanup_read_notifications($notificationdeletetime);
+ }
+
$params = array('notificationdeletetime' => $notificationdeletetime);
$DB->delete_records_select('notifications', 'timeread < :notificationdeletetime', $params);
}
public function force_process_messages() {
return false;
}
-}
-
+ /**
+ * Allow processors to perform cleanup tasks for all notifications by overriding this method
+ *
+ * @since Moodle 3.9
+ * @param int $notificationdeletetime
+ * @return void
+ */
+ public function cleanup_all_notifications(int $notificationdeletetime): void {
+ return;
+ }
+ /**
+ * Allow processors to perform cleanup tasks for read notifications by overriding this method
+ *
+ * @since Moodle 3.9
+ * @param int $notificationdeletetime
+ * @return void
+ */
+ public function cleanup_read_notifications(int $notificationdeletetime): void {
+ return;
+ }
+}
information provided here is intended especially for developers.
=== 3.9 ===
+
* Removed the following deprecated functions:
- message_move_userfrom_unread2read
- message_get_blocked_users
- message_mark_message_read
- message_can_delete_message
- message_delete_message
- * mark_all_read_for_user()
+ - mark_all_read_for_user()
+* Message processors can implement the following methods which will be executed as part of the messaging cleanup task:
+ - cleanup_all_notifications
+ - cleanup_read_notifications
=== 3.8 ===