Skip to content

Commit

Permalink
MDL-63867 tool_dataprivacy: Fix context expired/unprotected user check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mickhawkins committed Nov 9, 2018
1 parent bebef89 commit 0646c85
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions admin/tool/dataprivacy/classes/expired_contexts_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,11 @@ protected static function are_user_context_dependencies_expired(\context_user $c
* @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) {
Expand Down

0 comments on commit 0646c85

Please sign in to comment.