Skip to content

Commit

Permalink
MDL-82932 mod_data: Fix export with userdata of deleted users
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed Nov 11, 2024
1 parent 2b337b4 commit 5cceecc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mod/data/classes/local/exporter/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ public static function data_exportdata(int $dataid, array $fields, array $select
}
if ($userdetails) { // Add user details to the export data.
$userdata = get_complete_user_data('id', $record->userid);
$exporter->add_to_current_row(fullname($userdata));
$exporter->add_to_current_row($userdata->username);
$exporter->add_to_current_row($userdata->email);
// In case of an already deleted user, we do not receive any userdata and export an empty string instead.
$exporter->add_to_current_row($userdata ? fullname($userdata) : '');
$exporter->add_to_current_row($userdata ? $userdata->username : '');
$exporter->add_to_current_row($userdata ? $userdata->email : '');
}
if ($time) { // Add time added / modified.
$exporter->add_to_current_row(userdate($record->timecreated));
Expand Down

0 comments on commit 5cceecc

Please sign in to comment.