Skip to content

Commit 290fa58

Browse files
Use external submission ID in judgehost API
Part of #3024 � Conflicts: � judge/judgedaemon.main.php
1 parent 7368c00 commit 290fa58

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

judge/judgedaemon.main.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ private function checkDiskSpace(string $workdirpath): void
624624

625625
private function judgingDirectory(string $workdirpath, array $judgeTask): string
626626
{
627-
if (filter_var($judgeTask['submitid'], FILTER_VALIDATE_INT) === false ||
627+
if (filter_var($judgeTask['submitid'], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[a-zA-Z0-9_.-]+$/']]) === false ||
628628
filter_var($judgeTask['jobid'], FILTER_VALIDATE_INT) === false) {
629629
error("Malformed data returned in judgeTask IDs: " . var_export($judgeTask, true));
630630
}
@@ -1289,7 +1289,7 @@ private function compile(
12891289

12901290
// Revoke readablity for domjudge-run user to this workdir.
12911291
chmod($workdir, 0700);
1292-
logmsg(LOG_NOTICE, "Judging s$judgeTask[submitid], task $judgeTask[judgetaskid]: compile error");
1292+
logmsg(LOG_NOTICE, "Judging $judgeTask[submitid], task $judgeTask[judgetaskid]: compile error");
12931293
return false;
12941294
}
12951295

@@ -1353,7 +1353,7 @@ private function compile(
13531353
// What does the exitcode mean?
13541354
if (!isset($this->EXITCODES[$retval])) {
13551355
alert('error');
1356-
$description = "Unknown exitcode from compile.sh for s$judgeTask[submitid]: $retval";
1356+
$description = "Unknown exitcode from compile.sh for $judgeTask[submitid]: $retval";
13571357
logmsg(LOG_ERR, $description);
13581358
$this->disable('compile_script', 'compile_script_id', $judgeTask['compile_script_id'], $description, $judgeTask['judgetaskid'], $compile_output);
13591359

@@ -1568,7 +1568,7 @@ private function runTestcase(
15681568
// What does the exitcode mean?
15691569
if (!isset($this->EXITCODES[$retval])) {
15701570
alert('error');
1571-
error("Unknown exitcode ($retval) from testcase_run.sh for s$judgeTask[submitid]");
1571+
error("Unknown exitcode ($retval) from testcase_run.sh for $judgeTask[submitid]");
15721572
}
15731573
$result = $this->EXITCODES[$retval];
15741574

webapp/src/Controller/API/JudgehostController.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function getJudgehostsAction(
114114
* Add a new judgehost to the list of judgehosts.
115115
* Also restarts (and returns) unfinished judgings.
116116
*
117-
* @return array<array{jobid: int, submitid: int}>
117+
* @return array<array{jobid: int, submitid: string}>
118118
* @throws NonUniqueResultException
119119
*/
120120
#[IsGranted('ROLE_JUDGEHOST')]
@@ -127,7 +127,7 @@ public function getJudgehostsAction(
127127
items: new OA\Items(
128128
properties: [
129129
new OA\Property(property: 'jobid', type: 'integer'),
130-
new OA\Property(property: 'submitid', type: 'integer'),
130+
new OA\Property(property: 'submitid', type: 'string'),
131131
],
132132
type: 'object'
133133
)
@@ -188,7 +188,7 @@ public function createJudgehostAction(Request $request): array
188188

189189
return array_map(fn(Judging $judging) => [
190190
'jobid' => $judging->getJudgingid(),
191-
'submitid' => $judging->getSubmission()->getSubmitid(),
191+
'submitid' => $judging->getSubmission()->getExternalid(),
192192
], $judgings);
193193
}
194194

@@ -460,8 +460,8 @@ public function updateJudgingAction(
460460
$problem = $submission->getProblem();
461461
$this->scoreboardService->calculateScoreRow($contest, $team, $problem);
462462

463-
$message = sprintf("submission %d, judging %d: compiler-error",
464-
$submission->getSubmitid(), $judging->getJudgingid());
463+
$message = sprintf("submission %s, judging %d: compiler-error",
464+
$submission->getExternalid(), $judging->getJudgingid());
465465
$this->dj->alert('reject', $message);
466466
});
467467
}
@@ -1119,7 +1119,7 @@ private function addSingleJudgingRun(
11191119
// this means that these alert messages should be treated as
11201120
// confidential information.
11211121
$msg = sprintf("submission %s, judging %s: %s",
1122-
$submission->getSubmitid(), $judging->getJudgingid(), $result);
1122+
$submission->getExternalid(), $judging->getJudgingid(), $result);
11231123
$this->dj->alert($result === 'correct' ? 'accept' : 'reject', $msg);
11241124

11251125
// Potentially send a balloon, i.e. if no verification required (case of verification required is
@@ -1224,7 +1224,7 @@ private function maybeUpdateActiveJudging(Judging $judging): void
12241224
* @return JudgehostFile[]
12251225
*/
12261226
#[IsGranted(new Expression("is_granted('ROLE_JURY') or is_granted('ROLE_JUDGEHOST')"))]
1227-
#[Rest\Get('/get_files/{type}/{id<\d+>}')]
1227+
#[Rest\Get('/get_files/{type}/{id}')]
12281228
#[OA\Response(
12291229
response: 200,
12301230
description: 'The files for the submission, testcase or script.',
@@ -1271,7 +1271,7 @@ public function getVersionCommands(string $judgetaskid): array
12711271
}
12721272

12731273
$submission = $this->em->getRepository(Submission::class)
1274-
->findOneBy(['submitid' => $judgeTask->getSubmitid()]);
1274+
->findByExternalId($judgeTask->getSubmitid());
12751275
if (!$submission) {
12761276
throw new HttpException(500, 'Unknown submission with submitid ' . $judgeTask->getSubmitid());
12771277
}
@@ -1335,7 +1335,7 @@ public function checkVersions(Request $request, string $judgetaskid): array
13351335
}
13361336

13371337
$submission = $this->em->getRepository(Submission::class)
1338-
->findOneBy(['submitid' => $judgeTask->getSubmitid()]);
1338+
->findByExternalId($judgeTask->getSubmitid());
13391339
if (!$submission) {
13401340
throw new BadRequestHttpException('Unknown submission with submitid ' . $judgeTask->getSubmitid());
13411341
}
@@ -1419,7 +1419,8 @@ private function getSourceFiles(string $id): array
14191419
$queryBuilder = $this->em->createQueryBuilder()
14201420
->from(SubmissionFile::class, 'f')
14211421
->select('f')
1422-
->andWhere('f.submission = :submitid')
1422+
->join('f.submission', 's')
1423+
->andWhere('s.externalid = :submitid')
14231424
->setParameter('submitid', $id)
14241425
->orderBy('f.ranknumber');
14251426

@@ -1837,7 +1838,7 @@ private function getJudgetasks(string|int|null $jobId, int $max_batchsize, Judge
18371838
->getQuery()
18381839
->execute();
18391840
$this->em->flush();
1840-
$this->dj->auditlog('queuetask', $jobId, 'deleted');
1841+
$this->dj->auditlog('queuetask', (string)$jobId, 'deleted');
18411842
} else {
18421843
return $this->serializeJudgeTasks($judgetasks, $judgehost);
18431844
}

webapp/src/Entity/JudgeTask.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class JudgeTask
7979
#[Serializer\VirtualProperty]
8080
#[Serializer\SerializedName('submitid')]
8181
#[Serializer\Type('string')]
82-
public function getSubmitid(): ?int
82+
public function getSubmitid(): ?string
8383
{
84-
return $this->submission?->getSubmitid();
84+
return $this->submission?->getExternalid();
8585
}
8686

8787

0 commit comments

Comments
 (0)