Skip to content

Commit 6663724

Browse files
Use two different variables for error tracking so the logic is more clear.
1 parent b13a771 commit 6663724

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

webapp/src/Service/ImportExportService.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,9 @@ public function importProblemsData(Contest $contest, array $problems, array &$id
330330
->setTimelimit($problemData['time_limit'] ?? 10)
331331
->setExternalid($problemData['id'] ?? $problemData['short-name'] ?? $problemLabel ?? null);
332332

333-
$hasErrors = false;
334-
$errors = $this->validator->validate($problem);
335-
if ($errors->count()) {
336-
$hasErrors = true;
333+
$errors = $this->validator->validate($problem);
334+
$hasProblemErrors = $errors->count();
335+
if ($hasProblemErrors) {
337336
/** @var ConstraintViolationInterface $error */
338337
foreach ($errors as $error) {
339338
$messages['danger'][] = sprintf(
@@ -353,9 +352,9 @@ public function importProblemsData(Contest $contest, array $problems, array &$id
353352
->setProblem($problem)
354353
->setContest($contest);
355354

356-
$errors = $this->validator->validate($contestProblem);
357-
if ($errors->count()) {
358-
$hasErrors = true;
355+
$errors = $this->validator->validate($contestProblem);
356+
$hasContestProblemErrors = $errors->count();
357+
if ($hasContestProblemErrors) {
359358
/** @var ConstraintViolationInterface $error */
360359
foreach ($errors as $error) {
361360
$messages['danger'][] = sprintf(
@@ -367,7 +366,7 @@ public function importProblemsData(Contest $contest, array $problems, array &$id
367366
}
368367
}
369368

370-
if ($hasErrors) {
369+
if ($hasProblemErrors || $hasContestProblemErrors) {
371370
return false;
372371
}
373372

0 commit comments

Comments
 (0)