Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions classes/submission/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ protected function mapByProperties(array $props, Submission $submission, bool|Co

$reviewRounds = $this->getGroupedReviewRoundsFromSubmission($submission);
$currentReviewRound = $reviewRounds->flatten()->sort()->last(); /** @var ReviewRound|null $currentReviewRound */
// normalizing possibly null collections
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hafsa-Naeem, are these changes due to a case you encountered where $stageAssignments or $reviewAssignments is null? Or is it just the potential for that situation based e.g. on the typehint in the class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmecher Yes, this was from a real case in OMP. After allowing managers/editors to access submissions they're not assigned to, the reviewAssignments and stageAssignments were null and caused a fatal error in mapByProperties().

$stageAssignments = $this->stageAssignments ?? collect();
$reviewAssignments = $this->reviewAssignments ?? collect();

foreach ($props as $prop) {
switch ($prop) {
case 'recommendationsIn':
$output[$prop] = $currentReviewRound ? $this->areRecommendationsIn($currentReviewRound, $this->stageAssignments) : null;
$output[$prop] = $currentReviewRound ? $this->areRecommendationsIn($currentReviewRound, $stageAssignments) : null;
break;
case 'reviewersNotAssigned':
$output[$prop] = $currentReviewRound && $this->reviewAssignments->count() >= intval($this->context->getData('numReviewersPerSubmission'));
$required = $this->context->getNumReviewsPerSubmission();
$output[$prop] = $currentReviewRound && $reviewAssignments->count() < $required;
break;
case 'reviewRounds':
$output[$prop] = $this->getPropertyReviewRounds($reviewRounds->flatten());
Expand Down