Skip to content

Commit

Permalink
Prevent export crash due to missing user context
Browse files Browse the repository at this point in the history
After user data removal by tool_dataprivacy
`tool_dataprivacy\task\expired_retention_period` is used to remove user contexts

When exporting appointments with custom profile field selected this lead
to a crash.
This is due to profile field visibility check using `profile_field_base::is_visible()`
which is calling `context_user::instance()` with default strictness
(`MUST_EXIST`)...leading to an exception when the context is removed.
  • Loading branch information
ak4t0sh committed Oct 20, 2023
1 parent 62dc7b2 commit 89dc953
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion exportlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,8 @@ public function get_header(scheduler $scheduler) {
* @return string the value of this field for the given data
*/
public function get_value(slot $slot, $appointment) {
if (!$appointment instanceof appointment || $appointment->studentid == 0) {
if (!$appointment instanceof appointment || $appointment->studentid == 0
|| !context_user::instance($appointment->studentid, IGNORE_MISSING)) {
return '';
}
$this->field->set_userid($appointment->studentid);
Expand Down

0 comments on commit 89dc953

Please sign in to comment.