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.
This commit is contained in:
Michael Hawkins
2018-11-09 15:21:39 +08:00
parent 4b681328f3
commit 052d678465
@@ -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) {