From b91cc081ffd2498971253488b6d5b538a53a497f Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Fri, 29 Nov 2024 09:53:25 +0000 Subject: [PATCH] Allow cohort sync scheduled task to fail silently when auth_oidc is not configured --- local/o365/classes/task/cohortsync.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/local/o365/classes/task/cohortsync.php b/local/o365/classes/task/cohortsync.php index 46faf5ae3..c58812cce 100644 --- a/local/o365/classes/task/cohortsync.php +++ b/local/o365/classes/task/cohortsync.php @@ -25,6 +25,7 @@ namespace local_o365\task; +use core\exception\moodle_exception; use core\task\scheduled_task; use local_o365\feature\cohortsync\main; use local_o365\utils; @@ -48,8 +49,14 @@ public function get_name(): string { * @return bool */ public function execute(): bool { - $graphclient = main::get_unified_api(__METHOD__); - if (empty($graphclient)) { + try { + $graphclient = main::get_unified_api(__METHOD__); + if (empty($graphclient)) { + utils::mtrace("Failed to get Graph API client. Exiting.", 1); + + return true; + } + } catch (moodle_exception $e) { utils::mtrace("Failed to get Graph API client. Exiting.", 1); return true;