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.
* @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) {