MDL-69615 core_backup: Send backup report email once the tasks are done

This commit is contained in:
Huong Nguyen
2024-01-16 09:31:03 +07:00
parent 42b22b46fe
commit 806dcd5eee
6 changed files with 288 additions and 6 deletions
+20 -1
View File
@@ -32,9 +32,28 @@ trait task_trait {
*/
protected function execute_task(string $taskclass): void {
// Run the scheduled task.
ob_start();
$this->start_output_buffering();
$task = manager::get_scheduled_task($taskclass);
$task->execute();
$this->stop_output_buffering();
}
/**
* Helper to start output buffering.
*/
protected function start_output_buffering(): void {
ob_start();
}
/**
* Helper to stop output buffering.
*
* @return string|null The output buffer contents or null if output buffering is not active.
*/
protected function stop_output_buffering(): ?string {
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}