Skip to content

Commit

Permalink
Merge pull request pkp#8501 from Vitaliy-1/i8493_uploader_null
Browse files Browse the repository at this point in the history
pkp#8493 submission's uploaded user ID can be null
  • Loading branch information
Vitaliy-1 authored Feb 15, 2023
2 parents ca19ff5 + 5306729 commit 53b7c6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion classes/submissionFile/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ protected function mapByProperties(array $props, SubmissionFile $submissionFile)
}

if ($prop === 'uploaderUserName') {
$user = Repo::user()->get($submissionFile->getData('uploaderUserId'));
$userId = $submissionFile->getData('uploaderUserId');
$user = !is_null($userId) ? Repo::user()->get($userId) : null; // userId can be null, see pkp/pkp-lib#8493
$output[$prop] = $user?->getUsername() ?? '';

continue;
Expand Down
8 changes: 5 additions & 3 deletions schemas/submissionFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"fileId",
"fileStage",
"name",
"submissionId",
"uploaderUserId"
"submissionId"
],
"properties": {
"_href": {
Expand Down Expand Up @@ -260,7 +259,10 @@
},
"uploaderUserId": {
"type": "integer",
"apiSummary": true
"apiSummary": true,
"validation": [
"nullable"
]
},
"uploaderUserName": {
"type": "string",
Expand Down

0 comments on commit 53b7c6a

Please sign in to comment.