From 052d6784656bf286c9134c90e347c840c922f1bd Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Wed, 7 Nov 2018 13:53:52 +0800 Subject: [PATCH] MDL-63867 tool_dataprivacy: Fix context expired/unprotected user check It now checks the system context has been defined, since that is required for data privacy to be set up correctly, and the check to be valid. This also fixes an error being thrown when checking pending delete requests in cron. --- admin/tool/dataprivacy/classes/expired_contexts_manager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/admin/tool/dataprivacy/classes/expired_contexts_manager.php b/admin/tool/dataprivacy/classes/expired_contexts_manager.php index c2dc16949a5..751ee1ad573 100644 --- a/admin/tool/dataprivacy/classes/expired_contexts_manager.php +++ b/admin/tool/dataprivacy/classes/expired_contexts_manager.php @@ -887,6 +887,11 @@ class expired_contexts_manager { * @return bool */ public static function is_context_expired_or_unprotected_for_user(\context $context, \stdClass $user) : bool { + // User/course contexts can't expire if no purpose is set in the system context. + if (!data_registry::defaults_set()) { + return false; + } + $parents = $context->get_parent_contexts(true); foreach ($parents as $parent) { if ($parent instanceof \context_course) {