From c2f323e199b192c5916026b69db2c1ff16b5b143 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 16 Jun 2024 15:50:46 +0200 Subject: [PATCH 01/30] Don't run composer as root if unneeded We now track the autoload_runtime file and create it as the normal user and because it exists we don't recreate it in the install-domserver step as root (assuming it runs with `sudo`). It will still create it if it doesn't exist, because domserver is a dependency for install-domserver (and in that case `composer` would run as root again, so prompting the user to accept this risk). This also works for the inplace targets as those depend on `build` which runs the `domserver` part. (cherry picked from commit b40438377cc2c49b3f82a7f8bb2d7e34c02fca5f) --- Makefile | 14 ++++---------- lib/Makefile | 5 +++++ lib/vendor/Makefile | 12 ++++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 lib/vendor/Makefile diff --git a/Makefile b/Makefile index df4f2069a0..1f8bea7047 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ endif domserver: domserver-configure paths.mk config judgehost: judgehost-configure paths.mk config docs: paths.mk config -install-domserver: domserver composer-dump-autoload domserver-create-dirs +install-domserver: domserver domserver-create-dirs install-judgehost: judgehost judgehost-create-dirs install-docs: docs-create-dirs dist: configure composer-dependencies @@ -76,12 +76,6 @@ endif composer-dependencies-dev: composer $(subst 1,-q,$(QUIET)) install --prefer-dist --no-scripts --no-plugins -# Dump autoload dependencies (including plugins) -# This is needed since symfony/runtime is a Composer plugin that runs while dumping -# the autoload file -composer-dump-autoload: - composer $(subst 1,-q,$(QUIET)) dump-autoload -o -a - composer-dump-autoload-dev: composer $(subst 1,-q,$(QUIET)) dump-autoload @@ -101,7 +95,7 @@ build-scripts: # List of SUBDIRS for recursive targets: build: SUBDIRS= lib misc-tools -domserver: SUBDIRS=etc sql misc-tools webapp +domserver: SUBDIRS=etc lib sql misc-tools webapp install-domserver: SUBDIRS=etc lib sql misc-tools webapp example_problems judgehost: SUBDIRS=etc judge misc-tools install-judgehost: SUBDIRS=etc lib judge misc-tools @@ -222,7 +216,7 @@ webapp/.env.local: # symlinks where necessary to let it work from the source tree. # This stuff is a hack! maintainer-install: inplace-install composer-dump-autoload-dev -inplace-install: build composer-dump-autoload domserver-create-dirs judgehost-create-dirs +inplace-install: build domserver-create-dirs judgehost-create-dirs inplace-install-l: # Replace libjudgedir with symlink to prevent lots of symlinks: -rmdir $(judgehost_libjudgedir) @@ -341,5 +335,5 @@ clean-autoconf: $(addprefix inplace-,conf conf-common install uninstall) \ $(addprefix maintainer-,conf install) clean-autoconf config distdocs \ composer-dependencies composer-dependencies-dev \ - composer-dump-autoload composer-dump-autoload-dev \ + composer-dump-autoload-dev \ coverity-conf coverity-build diff --git a/lib/Makefile b/lib/Makefile index 5f2e2dea76..24cd0f82de 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,6 +1,9 @@ ifndef TOPDIR TOPDIR=.. endif + +REC_TARGETS = domserver + include $(TOPDIR)/Makefile.global OBJECTS = $(addsuffix $(OBJEXT),lib.error lib.misc) @@ -31,3 +34,5 @@ install-domserver: install-judgehost: $(INSTALL_DATA) -t $(DESTDIR)$(judgehost_libdir) *.php *.sh $(INSTALL_PROG) -t $(DESTDIR)$(judgehost_libdir) alert + +domserver: SUBDIRS=vendor diff --git a/lib/vendor/Makefile b/lib/vendor/Makefile new file mode 100644 index 0000000000..b6ee26a361 --- /dev/null +++ b/lib/vendor/Makefile @@ -0,0 +1,12 @@ +ifndef TOPDIR +TOPDIR=../.. +endif +include $(TOPDIR)/Makefile.global + +clean-l: + rm -f autoload_runtime.php + +autoload_runtime.php: + composer $(subst 1,-q,$(QUIET)) dump-autoload -o -a -d $(TOPDIR) + +domserver: autoload_runtime.php From 762ac7ddd949680118d1f94be9c7125602870d5e Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Fri, 7 Jun 2024 19:34:57 +0200 Subject: [PATCH 02/30] Refer to correct field to prevent HTTP500 This triggered an error and broke the webstandard test. (cherry picked from commit 68628406189d127cc74ca1233f33a65a5c3ec76a) --- webapp/src/Controller/Jury/TeamCategoryController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/Controller/Jury/TeamCategoryController.php b/webapp/src/Controller/Jury/TeamCategoryController.php index 2cdba5b922..0cc075696c 100644 --- a/webapp/src/Controller/Jury/TeamCategoryController.php +++ b/webapp/src/Controller/Jury/TeamCategoryController.php @@ -250,7 +250,7 @@ public function requestRemainingRunsWholeTeamCategoryAction(string $categoryId): ->join('t.category', 'tc') ->andWhere('j.valid = true') ->andWhere('j.result != :compiler_error') - ->andWhere('tc.category = :categoryId') + ->andWhere('tc.categoryid = :categoryId') ->setParameter('compiler_error', 'compiler-error') ->setParameter('categoryId', $categoryId); if ($contestId > -1) { From 2ccabd25a1de427672826aa92bd612c90eb9651a Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 9 Jun 2024 22:11:04 +0200 Subject: [PATCH 03/30] Disable (broken) Mayhem tests The authentication fails so needs to be rewritten with the new github action. --- .github/workflows/mayhem-api-template.yml | 93 ----------------------- .github/workflows/mayhem-daily.yml | 14 ---- .github/workflows/mayhem-weekly.yml | 25 ------ 3 files changed, 132 deletions(-) delete mode 100644 .github/workflows/mayhem-api-template.yml delete mode 100644 .github/workflows/mayhem-daily.yml delete mode 100644 .github/workflows/mayhem-weekly.yml diff --git a/.github/workflows/mayhem-api-template.yml b/.github/workflows/mayhem-api-template.yml deleted file mode 100644 index 9556bb3718..0000000000 --- a/.github/workflows/mayhem-api-template.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: "Mayhem API analysis (Template)" - -on: - workflow_call: - inputs: - version: - required: true - type: string - duration: - required: true - type: string - secrets: - MAPI_TOKEN: - required: true - -jobs: - mayhem: - name: Mayhem API analysis - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - env: - DB_DATABASE: domjudge - DB_USER: user - DB_PASSWORD: password - steps: - - uses: actions/checkout@v4 - - - name: Install DOMjudge - run: .github/jobs/baseinstall.sh ${{ inputs.version }} - - - name: Dump the OpenAPI - run: .github/jobs/getapi.sh - - - uses: actions/upload-artifact@v3 - if: ${{ inputs.version == 'guest' }} - with: - name: all-apispec - path: | - /home/runner/work/domjudge/domjudge/openapi.json - - - name: Mayhem for API - uses: ForAllSecure/mapi-action@v1 - if: ${{ inputs.version == 'guest' }} - continue-on-error: true - with: - mapi-token: ${{ secrets.MAPI_TOKEN }} - api-url: http://localhost/domjudge - api-spec: http://localhost/domjudge/api/doc.json # swagger/openAPI doc hosted here - duration: "auto" # Only spend time if we need to recheck issues from last time or find issues - sarif-report: mapi.sarif - run-args: | - --config - .github/jobs/data/mapi.config - --ignore-endpoint - ".*strict=true.*" - --ignore-endpoint - ".*strict=True.*" - - - name: Mayhem for API (For application role) - uses: ForAllSecure/mapi-action@v1 - if: ${{ inputs.version != 'guest' }} - continue-on-error: true - with: - mapi-token: ${{ secrets.MAPI_TOKEN }} - target: domjudge-${{ inputs.version }} - api-url: http://localhost/domjudge - api-spec: http://localhost/domjudge/api/doc.json # swagger/openAPI doc hosted here - duration: "${{ inputs.duration }}" - sarif-report: mapi.sarif - run-args: | - --config - .github/jobs/data/mapi.config - --basic-auth - admin:password - --ignore-endpoint - ".*strict=true.*" - --ignore-endpoint - ".*strict=True.*" - - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v2 - with: - sarif_file: mapi.sarif - - - uses: actions/upload-artifact@v3 - with: - name: ${{ inputs.version }}-logs - path: | - /var/log/nginx - /opt/domjudge/domserver/webapp/var/log/*.log diff --git a/.github/workflows/mayhem-daily.yml b/.github/workflows/mayhem-daily.yml deleted file mode 100644 index 2118bf6920..0000000000 --- a/.github/workflows/mayhem-daily.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: "Mayhem API daily (admin role only)" - -on: - schedule: - - cron: '0 23 * * *' - -jobs: - mayhem-template: - uses: ./.github/workflows/mayhem-api-template.yml - with: - version: "admin" - duration: "auto" - secrets: - MAPI_TOKEN: ${{ secrets.MAPI_TOKEN }} diff --git a/.github/workflows/mayhem-weekly.yml b/.github/workflows/mayhem-weekly.yml deleted file mode 100644 index 71cc90ecba..0000000000 --- a/.github/workflows/mayhem-weekly.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "Mayhem API weekly (all roles)" - -on: - schedule: - - cron: '0 23 * * 0' - -jobs: - mayhem-template: - strategy: - matrix: - include: - - version: "team" - duration: "5m" - - version: "guest" - duration: "auto" - - version: "jury" - duration: "5min" - - version: "admin" - duration: "10m" - uses: ./.github/workflows/mayhem-api-template.yml - with: - version: "${{ matrix.version }}" - duration: "${{ matrix.duration }}" - secrets: - MAPI_TOKEN: ${{ secrets.MAPI_TOKEN }} From f0218fc3e902eaf0ed3b615a135c8506b915c922 Mon Sep 17 00:00:00 2001 From: Dup4 Date: Sun, 16 Jun 2024 14:27:08 +0800 Subject: [PATCH 04/30] fix: time_limit type in ProblemEvent Object Signed-off-by: Dup4 --- webapp/src/DataTransferObject/Shadowing/ProblemEvent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/DataTransferObject/Shadowing/ProblemEvent.php b/webapp/src/DataTransferObject/Shadowing/ProblemEvent.php index 2aa47e6e27..7c5b76d348 100644 --- a/webapp/src/DataTransferObject/Shadowing/ProblemEvent.php +++ b/webapp/src/DataTransferObject/Shadowing/ProblemEvent.php @@ -7,7 +7,7 @@ class ProblemEvent implements EventData public function __construct( public readonly string $id, public readonly string $name, - public readonly int $timeLimit, + public readonly float $timeLimit, public readonly ?string $label, public readonly ?string $rgb, ) {} From 83d5836d0314a12ef5d03dd2dd92046a0d4acd13 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Wed, 19 Jun 2024 20:49:52 +0200 Subject: [PATCH 05/30] Escape \ in Python strings It seems Python complains about this for some Python versions. --- misc-tools/import-contest.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc-tools/import-contest.in b/misc-tools/import-contest.in index 756c03d7f0..79d6ffaa9a 100755 --- a/misc-tools/import-contest.in +++ b/misc-tools/import-contest.in @@ -149,10 +149,10 @@ if import_file('organizations', ['organizations.json']): # Also import logos if we have any # We prefer the 64x64 logo. If it doesn't exist, accept a generic logo (which might be a SVG) # We also prefer PNG/SVG before JPG - import_images('organizations', 'logo', ['^logo\.64x\d+\.png$', '^logo\.(png|svg)$', '^logo\.64x\d+\.jpg$', '^logo\.jpg$']) + import_images('organizations', 'logo', ['^logo\\.64x\\d+\\.png$', '^logo\\.(png|svg)$', '^logo\\.64x\\d+\\.jpg$', '^logo\\.jpg$']) if import_file('teams', ['teams.json', 'teams2.tsv']): # Also import photos if we have any, but prefer JPG over SVG and PNG - import_images('teams', 'photo', ['^photo\.jpg$', '^photo\.(png|svg)$']) + import_images('teams', 'photo', ['^photo\\.jpg$', '^photo\\.(png|svg)$']) import_file('accounts', ['accounts.json', 'accounts.yaml', 'accounts.tsv']) problems_imported = False From 0f59e75371452da6b1b1fc052f33840242f2e861 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 16 Jun 2024 14:47:52 +0800 Subject: [PATCH 06/30] ui: problem_list: fix line break --- webapp/templates/partials/problem_list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/templates/partials/problem_list.html.twig b/webapp/templates/partials/problem_list.html.twig index f00ef14482..0733241ddd 100644 --- a/webapp/templates/partials/problem_list.html.twig +++ b/webapp/templates/partials/problem_list.html.twig @@ -94,7 +94,7 @@ data-bs-toggle="tooltip" data-placement="top" data-html="true" - title="Between {{ stat.start.timestamp | printtime(null, contest) }} and {{ stat.end.timestamp | printtime(null, contest) }}:
{{ label }}"> + title="Between {{ stat.start.timestamp | printtime(null, contest) }} and {{ stat.end.timestamp | printtime(null, contest) }}:{{ '\n' }}{{ label }}"> {% endfor %} From 063824ce24fd2108124fb11c067d517d6a8d3b5d Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 20:03:31 +0800 Subject: [PATCH 07/30] Revert "Select shortname from current contestproblem" This reverts commit 0219d8e173540e26b5867d219753dcb23f08fcc5. (cherry picked from commit 98c29f714d56b7e4dddbd46d208f145f60bb2c2c) --- webapp/src/Controller/Team/MiscController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/webapp/src/Controller/Team/MiscController.php b/webapp/src/Controller/Team/MiscController.php index 648b4bf727..e714d6737b 100644 --- a/webapp/src/Controller/Team/MiscController.php +++ b/webapp/src/Controller/Team/MiscController.php @@ -95,12 +95,10 @@ public function homeAction(Request $request): Response $clarifications = $this->em->createQueryBuilder() ->from(Clarification::class, 'c') ->leftJoin('c.problem', 'p') - ->leftJoin('p.contest_problems', 'cp') ->leftJoin('c.sender', 's') ->leftJoin('c.recipient', 'r') - ->select('c', 'cp', 'p') + ->select('c', 'p') ->andWhere('c.contest = :contest') - ->andWhere('cp.contest = :contest') ->andWhere('c.sender IS NULL') ->andWhere('c.recipient = :team OR c.recipient IS NULL') ->setParameter('contest', $contest) @@ -114,12 +112,10 @@ public function homeAction(Request $request): Response $clarificationRequests = $this->em->createQueryBuilder() ->from(Clarification::class, 'c') ->leftJoin('c.problem', 'p') - ->leftJoin('p.contest_problems', 'cp') ->leftJoin('c.sender', 's') ->leftJoin('c.recipient', 'r') - ->select('c', 'cp', 'p') + ->select('c', 'p') ->andWhere('c.contest = :contest') - ->andWhere('cp.contest = :contest') ->andWhere('c.sender = :team') ->setParameter('contest', $contest) ->setParameter('team', $team) From 9d228e93efa77cbaa89c1c6450629a61e4eaaa84 Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 20:10:24 +0800 Subject: [PATCH 08/30] Add `getContestProblem` to Contest for getting an associated ContestProblem (cherry picked from commit 56104f63024f11599719b1e4553d732cf8e6cbce) --- webapp/src/Entity/Contest.php | 10 ++++++++++ webapp/src/Twig/TwigExtension.php | 11 ++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/webapp/src/Entity/Contest.php b/webapp/src/Entity/Contest.php index 0b88932cd6..9c5cfe6ab3 100644 --- a/webapp/src/Entity/Contest.php +++ b/webapp/src/Entity/Contest.php @@ -913,6 +913,16 @@ public function getProblems(): Collection return $this->problems; } + public function getContestProblem(Problem $problem): ?ContestProblem + { + foreach ($this->getProblems() as $contestProblem) { + if ($contestProblem->getProblem() === $problem) { + return $contestProblem; + } + } + return null; + } + public function addClarification(Clarification $clarification): Contest { $this->clarifications[] = $clarification; diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 7238f43682..3fd902e29f 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -1093,14 +1093,11 @@ public function problemBadge(ContestProblem $problem): string ); } - public function problemBadgeForProblemAndContest(Problem $problem, ?Contest $contest): string + public function problemBadgeForProblemAndContest(Problem $problem, ?Contest $contest = null): string { - foreach ($problem->getContestProblems() as $contestProblem) { - if ($contestProblem->getContest() === $contest) { - return $this->problemBadge($contestProblem); - } - } - return ''; + $contest ??= $this->dj->getCurrentContest(); + $contestProblem = $contest?->getContestProblem($problem); + return $contestProblem === null ? '' : $this->problemBadge($contestProblem); } public function printMetadata(?string $metadata): string From cddeaf14d733923ca812aad6547de9a2d07c99a8 Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 22:45:39 +0800 Subject: [PATCH 09/30] Rename `problemBadgeForProblemAndContest` to `problemBadgeForContest` (cherry picked from commit eaf95fecd838f6774494db1411bb07710ce41d88) --- webapp/src/Twig/TwigExtension.php | 4 ++-- webapp/templates/jury/executable.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 3fd902e29f..deff4a4f9c 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -108,7 +108,7 @@ public function getFilters(): array new TwigFilter('tsvField', $this->toTsvField(...)), new TwigFilter('fileTypeIcon', $this->fileTypeIcon(...)), new TwigFilter('problemBadge', $this->problemBadge(...), ['is_safe' => ['html']]), - new TwigFilter('problemBadgeForProblemAndContest', $this->problemBadgeForProblemAndContest(...), ['is_safe' => ['html']]), + new TwigFilter('problemBadgeForContest', $this->problemBadgeForContest(...), ['is_safe' => ['html']]), new TwigFilter('printMetadata', $this->printMetadata(...), ['is_safe' => ['html']]), new TwigFilter('printWarningContent', $this->printWarningContent(...), ['is_safe' => ['html']]), new TwigFilter('entityIdBadge', $this->entityIdBadge(...), ['is_safe' => ['html']]), @@ -1093,7 +1093,7 @@ public function problemBadge(ContestProblem $problem): string ); } - public function problemBadgeForProblemAndContest(Problem $problem, ?Contest $contest = null): string + public function problemBadgeForContest(Problem $problem, ?Contest $contest = null): string { $contest ??= $this->dj->getCurrentContest(); $contestProblem = $contest?->getContestProblem($problem); diff --git a/webapp/templates/jury/executable.html.twig b/webapp/templates/jury/executable.html.twig index 95cbe3956e..0cf94b261c 100644 --- a/webapp/templates/jury/executable.html.twig +++ b/webapp/templates/jury/executable.html.twig @@ -48,14 +48,14 @@ {% if executable.type == 'compare' %} {% for problem in executable.problemsCompare %} - p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }} + p{{ problem.probid }} {{ problem | problemBadgeForContest }} {% set used = true %} {% endfor %} {% elseif executable.type == 'run' %} {% for problem in executable.problemsRun %} - p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }} + p{{ problem.probid }} {{ problem | problemBadgeForContest }} {% set used = true %} {% endfor %} From 75c16e09a9d5435bbcbe34e4b3db8a6882b1efee Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 20:10:57 +0800 Subject: [PATCH 10/30] Fix #2279: get associated ContestProblem with Clarification entity (cherry picked from commit affacb4ed043efd88c5d7e51f2ea8fdddb9a0576) --- webapp/src/Entity/Clarification.php | 8 ++++++++ .../templates/jury/partials/clarification_list.html.twig | 2 +- webapp/templates/team/partials/clarification.html.twig | 2 +- .../templates/team/partials/clarification_list.html.twig | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/webapp/src/Entity/Clarification.php b/webapp/src/Entity/Clarification.php index ed62d6013f..b52765b218 100644 --- a/webapp/src/Entity/Clarification.php +++ b/webapp/src/Entity/Clarification.php @@ -236,6 +236,14 @@ public function getProblem(): ?Problem return $this->problem; } + public function getContestProblem(): ?ContestProblem + { + if (!$this->problem) { + return null; + } + return $this->contest->getContestProblem($this->problem); + } + #[OA\Property(nullable: true)] #[Serializer\VirtualProperty] #[Serializer\SerializedName('problem_id')] diff --git a/webapp/templates/jury/partials/clarification_list.html.twig b/webapp/templates/jury/partials/clarification_list.html.twig index 337499bb1c..09874023be 100644 --- a/webapp/templates/jury/partials/clarification_list.html.twig +++ b/webapp/templates/jury/partials/clarification_list.html.twig @@ -71,7 +71,7 @@ {%- if clarification.problem -%} - problem {{ clarification.problem.contestProblems.first | problemBadge -}} + problem {{ clarification.contestProblem | problemBadge -}} {%- elseif clarification.category -%} {{- categories[clarification.category]|default('general') -}} {%- else -%} diff --git a/webapp/templates/team/partials/clarification.html.twig b/webapp/templates/team/partials/clarification.html.twig index eda98ce293..5004e4c0d4 100644 --- a/webapp/templates/team/partials/clarification.html.twig +++ b/webapp/templates/team/partials/clarification.html.twig @@ -4,7 +4,7 @@
Subject: {% if clarification.problem %} - Problem {{ clarification.problem.contestProblems.first.shortname }}: {{ clarification.problem.name }} + Problem {{ clarification.contestProblem.shortname }}: {{ clarification.problem.name }} {% elseif clarification.category %} {{ categories[clarification.category]|default('general') }} {% else %} diff --git a/webapp/templates/team/partials/clarification_list.html.twig b/webapp/templates/team/partials/clarification_list.html.twig index a36c1e0f30..47b154c542 100644 --- a/webapp/templates/team/partials/clarification_list.html.twig +++ b/webapp/templates/team/partials/clarification_list.html.twig @@ -44,7 +44,7 @@ {%- if clarification.problem -%} - problem {{ clarification.problem.contestProblems.first | problemBadge -}} + problem {{ clarification.contestProblem | problemBadge -}} {%- elseif clarification.category -%} {{- categories[clarification.category]|default('general') -}} {%- else -%} From 532f4ae6a7e3338ad46da9a66951a255288687d5 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sat, 20 Jul 2024 11:43:25 +0200 Subject: [PATCH 11/30] Fix CI In main this file already uses another image so composer was missing. --- .github/workflows/autoconf-check-different-distro.yml | 2 +- .github/workflows/autoconf-check.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/autoconf-check-different-distro.yml b/.github/workflows/autoconf-check-different-distro.yml index 8216eb3a26..9db54dfaa8 100644 --- a/.github/workflows/autoconf-check-different-distro.yml +++ b/.github/workflows/autoconf-check-different-distro.yml @@ -20,7 +20,7 @@ jobs: image: ${{ matrix.os }}:${{ matrix.version }} steps: - name: Install git so we get the .github directory - run: dnf install -y git + run: dnf install -y git composer - uses: actions/checkout@v4 - name: Setup image and run bats tests run: .github/jobs/configure-checks/setup_configure_image.sh diff --git a/.github/workflows/autoconf-check.yml b/.github/workflows/autoconf-check.yml index 016ec024f7..58f6f691d1 100644 --- a/.github/workflows/autoconf-check.yml +++ b/.github/workflows/autoconf-check.yml @@ -32,7 +32,7 @@ jobs: image: ${{ matrix.os }}:${{ matrix.version }} steps: - name: Install git so we get the .github directory - run: apt-get update; apt-get install -y git + run: apt-get update; apt-get install -y git composer - uses: actions/checkout@v4 - name: Setup image and run bats tests run: .github/jobs/configure-checks/setup_configure_image.sh From 92e3ad705cef4b6e4db2033751384327437e4a9a Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sat, 20 Jul 2024 10:25:17 +0200 Subject: [PATCH 12/30] Release the patch release --- ChangeLog | 3 +++ README.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 30ebc035f2..5bc6199478 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ DOMjudge Programming Contest Judging System +Version 8.3.1 - 21 July 2024 + - Create autoload_runtime.php as normal user to prevent a composer warning. + Version 8.3.0 - 31 May 2024 --------------------------- - [security] Close metadata file descriptor for the child in runguard. diff --git a/README.md b/README.md index 5499da3e0a..eaa23881ee 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ DOMjudge [![Coverity Scan Status](https://img.shields.io/coverity/scan/671.svg)](https://scan.coverity.com/projects/domjudge) [![CodeQL alerts](https://github.com/DOMjudge/domjudge/actions/workflows/codeql-analysis.yml/badge.svg?branch=main&event=push)](https://github.com/DOMjudge/domjudge/actions/workflows/codeql-analysis.yml) -This is the Programming Contest Jury System "DOMjudge" version 8.3.0 +This is the Programming Contest Jury System "DOMjudge" version 8.3.1 DOMjudge is a system for running a programming contest, like the ICPC regional and world championship programming contests. From 6f223eafe50a829887451127ae589379b44464e5 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:27:24 +0200 Subject: [PATCH 13/30] Fix start of MySQL container The native password module used was deprecated with MySQL8 and doesn't work with MySQL9 anymore. It seems we don't need it anymore (I think we needed it because the mariadb-utils did not have support for caching_sha2_password yet), but the alternative is to keep using the MySQL8 container and not test for MySQL9. Under the hood in the past we used to store the password as a hash in the mysql.user table and now it's stored in another way (https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password) which should also give better performance. See: https://dba.stackexchange.com/a/209520 (cherry picked from commit 9c2bb9906c384e6b4292ec973cbcf2edb392dd79) --- gitlab/ci/template.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/gitlab/ci/template.yml b/gitlab/ci/template.yml index 5b954aff68..1c75a358a9 100644 --- a/gitlab/ci/template.yml +++ b/gitlab/ci/template.yml @@ -36,7 +36,6 @@ - /bin/true services: - name: mysql - command: ["--mysql-native-password", "--authentication_policy=mysql_native_password"] alias: sqlserver .mariadb_job: From 719746d9b17ddc625ebcca88296be8070c7e25de Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Fri, 16 Aug 2024 07:51:35 +0200 Subject: [PATCH 14/30] Fix saving new problems with statements Fixes #2646. We used to persist the entity both before and after calling the lifecycle callbacks ourselves, which would introduce weird behavior where Doctrine wanted to insert some rows twice. By not persisting before calling the callbacks ourselves, this issue goes away. (cherry picked from commit 9f12b776881148aeb65e4c067e7290791752ea05) --- ChangeLog | 4 ++++ webapp/src/Controller/Jury/ProblemController.php | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5bc6199478..3436f74445 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ DOMjudge Programming Contest Judging System +Version 8.3.2 +--------------------------- + - Fix saving new problems with problem statement from web UI. + Version 8.3.1 - 21 July 2024 - Create autoload_runtime.php as normal user to prevent a composer warning. diff --git a/webapp/src/Controller/Jury/ProblemController.php b/webapp/src/Controller/Jury/ProblemController.php index 56ed94d5f8..95d40eafdb 100644 --- a/webapp/src/Controller/Jury/ProblemController.php +++ b/webapp/src/Controller/Jury/ProblemController.php @@ -1087,7 +1087,6 @@ public function addAction(Request $request): Response $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->em->persist($problem); $this->saveEntity($this->em, $this->eventLogService, $this->dj, $problem, null, true); return $this->redirectToRoute('jury_problem', ['probId' => $problem->getProbid()]); } From 3324986cd7243c31987fdbc976411027e6c610b6 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Fri, 13 Sep 2024 11:14:06 +0200 Subject: [PATCH 15/30] Release now as we didn't at that date --- ChangeLog | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3436f74445..ccd133df9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,9 @@ DOMjudge Programming Contest Judging System -Version 8.3.2 ---------------------------- - - Fix saving new problems with problem statement from web UI. - -Version 8.3.1 - 21 July 2024 +Version 8.3.1 - 13 September 2024 +--------------------------------- - Create autoload_runtime.php as normal user to prevent a composer warning. + - Fix saving new problems with problem statement from web UI. Version 8.3.0 - 31 May 2024 --------------------------- From 1ba02e7874e33beb63915778af75007cc2160c1c Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Fri, 13 Sep 2024 11:22:33 +0200 Subject: [PATCH 16/30] Upload of problem metadata uses another endpoint See: https://domjudge-org.slack.com/archives/CHHURFUM7/p1726156440653609?thread_ts=1726145487.583349&cid=CHHURFUM7 (cherry picked from commit 72b3b49ee1103af45ff71c86139f0e287f9ee9de) --- doc/manual/import.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/manual/import.rst b/doc/manual/import.rst index 2b685943b4..6994210f16 100644 --- a/doc/manual/import.rst +++ b/doc/manual/import.rst @@ -405,11 +405,11 @@ and click `Import`. To import the file using the API run the following commands:: - http --check-status -b -f POST "/contests//problems" data@problems.yaml + http --check-status -b -f POST "/contests//problems/add-data" data@problems.yaml To import the file using the CLI run the following command:: - /bin/console api:call -m POST -f data=problems.yaml contests//problems + /bin/console api:call -m POST -f data=problems.yaml contests//problems/add-data Replace ```` with the contest ID that was returned when importing the contest metadata. From adc65af0b19fd0b6be7d9273481fcffb8698cf0c Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 1 Sep 2024 00:10:41 +0200 Subject: [PATCH 17/30] Use the preg_match_all return to detect failures Even if we cannot match anything we would have had an array containing an empty array. That array indicates that nothing was matched. We should now fail when: - preg_match_all fails - preg_match_all returns it found 0 matches - the redundant case (as safeguard) when the array has 0 matches (cherry picked from commit 274d36ad2aba9ddc7669038b13262b875bede49b) --- webapp/src/Twig/TwigExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index deff4a4f9c..3972b77ed0 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -1032,8 +1032,8 @@ public function hexColorToRGBA(string $text, float $opacity = 1): string if (is_null($col)) { return $text; } - preg_match_all("/[0-9A-Fa-f]{2}/", $col, $m); - if (!count($m)) { + $ret = preg_match_all("/[0-9A-Fa-f]{2}/", $col, $m); + if (!($ret && count($m[0]))) { return $text; } From edab670539ef806131b34971c9c760e597a216e3 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 25 Aug 2024 11:51:47 +0200 Subject: [PATCH 18/30] Check for correct message The wrong state was picked in the past, PHPStan found this in an unrelated other issue. (cherry picked from commit bdd6ea39393af380687ef6efb59f2c87419ac462) --- webapp/tests/Unit/Controller/Jury/JuryMiscControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/tests/Unit/Controller/Jury/JuryMiscControllerTest.php b/webapp/tests/Unit/Controller/Jury/JuryMiscControllerTest.php index 31e9b0bf89..bda8ae8583 100644 --- a/webapp/tests/Unit/Controller/Jury/JuryMiscControllerTest.php +++ b/webapp/tests/Unit/Controller/Jury/JuryMiscControllerTest.php @@ -91,7 +91,7 @@ public function testBalloonScoreboard(array $fixtures, bool $public, string $con $elements = ["3 tries",'Demo contest','Utrecht University']; } elseif (in_array($contestStage, ['preEnd','preUnfreeze'])) { $elements = ["0 + 4 tries","3 tries","2 + 1 tries",'Demo contest','Utrecht University']; - if ($contestStage === 'preFreeze') { + if ($contestStage === 'preUnfreeze') { $elements[] = 'contest over, waiting for results'; } } else { From 71d057c2b3d3be266d8baea8f7246a8e70b7ebe5 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 25 Aug 2024 16:58:12 +0200 Subject: [PATCH 19/30] Extend bats test for new debian versions Debian testing started using different quotes in the generated configure scripts. Co-authored-by: Tobias Werth (cherry picked from commit c53ccda2c6ddb95b94d0b48ba14ce605bb38fa74) --- .github/jobs/configure-checks/all.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/jobs/configure-checks/all.bats b/.github/jobs/configure-checks/all.bats index 8f82797f8a..0b422e1067 100755 --- a/.github/jobs/configure-checks/all.bats +++ b/.github/jobs/configure-checks/all.bats @@ -67,9 +67,9 @@ repo-remove () { assert_line "checking for gcc... no" assert_line "checking for cc... no" assert_line "checking for cl.exe... no" - assert_line "configure: error: in \`${test_path}':" + assert_regex "configure: error: in .${test_path}':" assert_line 'configure: error: no acceptable C compiler found in $PATH' - assert_line "See \`config.log' for more details" + assert_regex "See [\`']config.log' for more details" } compiler_assertions () { From baf987627838c68b0585e8800d124e8d8cc20f57 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Mon, 21 Oct 2024 19:56:31 +0200 Subject: [PATCH 20/30] Add note about setting the force flag for cgroup v1 very new systemd versions --- doc/manual/install-judgehost.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/manual/install-judgehost.rst b/doc/manual/install-judgehost.rst index fafe28c7f8..24c69bba55 100644 --- a/doc/manual/install-judgehost.rst +++ b/doc/manual/install-judgehost.rst @@ -172,7 +172,8 @@ any other tasks on the same CPU core the judgedaemon is using: On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have cgroup v2 enabled by default, you need to add ``systemd.unified_cgroup_hierarchy=0`` -as well. Then run ``update-grub`` and reboot. +as well. If you are running systemd v257, you also need to add `SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1`. +Then run ``update-grub`` and reboot. After rebooting check that ``/proc/cmdline`` actually contains the added kernel options. On VM hosting providers such as Google Cloud or DigitalOcean, ``GRUB_CMDLINE_LINUX_DEFAULT`` may be overwritten From bb01c9c23a68feab74a8920b8d365b6c570b3826 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Fri, 21 Jun 2024 09:02:47 +0200 Subject: [PATCH 21/30] Use correct API doc root by reading it from the request Fixes #2611 Also we should not append /api since the swagger already does this. (cherry picked from commit 7858e80f6eef33a749a845edd054d812b11507d9) --- webapp/config/packages/nelmio_api_doc.yaml | 4 +-- .../ExternalDocDescriber.php | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 webapp/src/NelmioApiDocBundle/ExternalDocDescriber.php diff --git a/webapp/config/packages/nelmio_api_doc.yaml b/webapp/config/packages/nelmio_api_doc.yaml index 2453372b42..5904171595 100644 --- a/webapp/config/packages/nelmio_api_doc.yaml +++ b/webapp/config/packages/nelmio_api_doc.yaml @@ -1,9 +1,9 @@ nelmio_api_doc: documentation: servers: - - url: "%domjudge.baseurl%api" + - url: ~ # Will be set by App\NelmioApiDocBundle\ExternalDocDescriber description: API used at this contest - - url: https://www.domjudge.org/demoweb/api + - url: https://www.domjudge.org/demoweb description: New API in development info: title: DOMjudge diff --git a/webapp/src/NelmioApiDocBundle/ExternalDocDescriber.php b/webapp/src/NelmioApiDocBundle/ExternalDocDescriber.php new file mode 100644 index 0000000000..2805d51b55 --- /dev/null +++ b/webapp/src/NelmioApiDocBundle/ExternalDocDescriber.php @@ -0,0 +1,29 @@ +requestStack->getCurrentRequest(); + $this->decorated->describe($api); + Util::merge($api->servers[0], ['url' => $request->getSchemeAndHttpHost(),], true); + } +} From 603fa9c397d074c55a5927616cdcbde380c5c000 Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+vmcj@users.noreply.github.com> Date: Fri, 1 Nov 2024 09:34:36 +0100 Subject: [PATCH 22/30] Skip C++ test for fedora Fedora 41 seems to ship with C++ support either in the package or via dependencies. Exclude it as a quick fix. (cherry picked from commit fb67ba708f9f9b93387898935c33f652598c4102) --- .github/jobs/configure-checks/all.bats | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/jobs/configure-checks/all.bats b/.github/jobs/configure-checks/all.bats index 0b422e1067..666d391564 100755 --- a/.github/jobs/configure-checks/all.bats +++ b/.github/jobs/configure-checks/all.bats @@ -111,6 +111,10 @@ compile_assertions_finished () { } @test "Install GNU C only" { + if [ "$distro_id" = "ID=fedora" ]; then + # Fedora ships with a gcc with enough C++ support + skip + fi repo-remove clang g++ repo-install gcc libcgroup-dev compiler_assertions gcc '' From 23612a071c40cc40d068dce4d4f73eb36159c472 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Tue, 12 Nov 2024 14:08:12 +0100 Subject: [PATCH 23/30] Use PHPStan version from composer (cherry picked from commit f90dbe542f251fba2ba90eb6eae49700641fb29c) --- .github/workflows/phpstan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index d2577b6018..fb628abaf4 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -21,3 +21,4 @@ jobs: configuration: phpstan.dist.neon path: webapp/src webapp/tests php_extensions: gd intl mysqli pcntl zip + version: composer From 00c74ecc826634cdc1e337bd21cae60b9fcaae2d Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Mon, 19 Aug 2024 22:43:34 +0200 Subject: [PATCH 24/30] Update broken link to problem package format Also point to the legacy ICPC version for now. A new version is planned to be released in September around the ICPC World Finals in Astana, but until that's finalized, point to what we're actually (roughly) implementing currently. (cherry picked from commit 11fe36fd45e0cb1d4bd7e25e1a653279f35e105e) --- doc/manual/problem-format.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/problem-format.rst b/doc/manual/problem-format.rst index e9f6cbc300..4439cedc2d 100644 --- a/doc/manual/problem-format.rst +++ b/doc/manual/problem-format.rst @@ -54,4 +54,4 @@ problem by uploading a zip file that contains only testcase files. Any jury solutions present will be automatically submitted when ``allow_submit`` is ``1`` and there's a team associated with the uploading user. -.. _ICPC problem package specification: https://icpc.io/problem-package-format/spec/problem_package_format +.. _ICPC problem package specification: https://icpc.io/problem-package-format/spec/legacy-icpc From ecc77b3abb60e27cc337708162228a3eb48733a9 Mon Sep 17 00:00:00 2001 From: Michael Vasseur Date: Fri, 29 Nov 2024 19:10:02 +0100 Subject: [PATCH 25/30] Show the PHPStan version Also pin to the second to last released version for the GHA as the last one crashes. (cherry picked from commit bf67a46e63546686de4fbd1135847069f6de2f82) --- .github/workflows/phpstan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index fb628abaf4..94197d7421 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - name: Install DOMjudge run: .github/jobs/baseinstall.sh admin - - uses: php-actions/phpstan@v3 + - uses: php-actions/phpstan@v3.0.2 with: configuration: phpstan.dist.neon path: webapp/src webapp/tests From abd1f3418ef05c4cfccfea05b7ebcab3b02cb7b5 Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Fri, 21 Mar 2025 13:48:37 +0100 Subject: [PATCH 26/30] Bump Debian debootstrap version The old version was not available anymore for download. (cherry picked from commit e6d7b4623924173c30f34e25ec2c6c04716757df) --- misc-tools/dj_make_chroot.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc-tools/dj_make_chroot.in b/misc-tools/dj_make_chroot.in index aa9f80e772..3d03f9935c 100755 --- a/misc-tools/dj_make_chroot.in +++ b/misc-tools/dj_make_chroot.in @@ -178,7 +178,7 @@ if [ "$DISTRO" = 'Debian' ]; then REMOVEDEBS="" # Which debootstrap package to install on non-Debian systems: - DEBOOTDEB="debootstrap_1.0.128+nmu2+deb12u1_all.deb" + DEBOOTDEB="debootstrap_1.0.128+nmu2+deb12u2_all.deb" # The Debian mirror/proxy below can be passed as environment # variables; if none are given the following defaults are used. From fad5cd6890ad0f580bd31f3072a42ba72bb3f9e4 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:18:13 +0200 Subject: [PATCH 27/30] Document that systemd files need to be copied Loosely based on: https://github.com/DOMjudge/domjudge/commit/ec7ca6c710d45b4bfa21e06be02d35d69a599998 --- doc/manual/install-judgehost.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/manual/install-judgehost.rst b/doc/manual/install-judgehost.rst index 24c69bba55..454e38246f 100644 --- a/doc/manual/install-judgehost.rst +++ b/doc/manual/install-judgehost.rst @@ -68,6 +68,15 @@ example to install DOMjudge in the directory ``domjudge`` under `/opt`:: make judgehost sudo make install-judgehost +Example service files for the judgehost and the judgedaemon are provided in +``judge/create-cgroups.service`` and ``judge/domjudge-judgedaemon@.service``. The rest of the manual assumes you install those +in a location which is picked up by ``systemd``, for example ``/etc/systemd/system``. + +.. parsed-literal:: + + cp judge/domjudge-judgedaemon@.service /etc/systemd/system/ + cp judge/create-cgroups.service /etc/systemd/system/ + The judgedaemon can be run on various hardware configurations; - A virtual machine, typically these have 1 or 2 cores and no hyperthreading, because the kernel will schedule its own tasks on CPU 0, we advice CPU 1, From f4be923e7e5634b23dd21754865dcee9f12c232f Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Sun, 16 Feb 2025 11:33:46 +0100 Subject: [PATCH 28/30] Fix codespell error. (cherry picked from commit df501ed653c634368ae4a8a1ba8d0450ffc9f15d) --- doc/manual/config-advanced.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/config-advanced.rst b/doc/manual/config-advanced.rst index 72b8016740..96150a8aeb 100644 --- a/doc/manual/config-advanced.rst +++ b/doc/manual/config-advanced.rst @@ -238,7 +238,7 @@ selected in the ``special_run`` and/or ``special_compare`` fields of the problem (an empty value means that the default run and compare scripts should be used; the defaults can be set in the global configuration settings). When creating custom run and compare -programs, we recommend re-using wrapper scripts that handle the +programs, we recommend reusing wrapper scripts that handle the tedious, standard part. See the boolfind example for details. Compare programs From 84925260ecf318c1911260b6a3ae71104fec9cb1 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sat, 5 Jul 2025 10:51:14 +0200 Subject: [PATCH 29/30] Expose samples/problemset after the contest start --- .../src/Controller/API/AbstractApiController.php | 15 ++++++++++++--- webapp/src/Controller/API/ContestController.php | 10 +++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/webapp/src/Controller/API/AbstractApiController.php b/webapp/src/Controller/API/AbstractApiController.php index 163f000bba..b5c43a76d9 100644 --- a/webapp/src/Controller/API/AbstractApiController.php +++ b/webapp/src/Controller/API/AbstractApiController.php @@ -34,9 +34,11 @@ public function __construct( * Get the query builder used for getting contests. * * @param bool $onlyActive return only contests that are active + * @param bool $filterBeforeContest return only contests that have started */ - protected function getContestQueryBuilder(bool $onlyActive = false): QueryBuilder - { + protected function getContestQueryBuilder( + bool $onlyActive = false, bool $filterBeforeContest = true + ): QueryBuilder { $now = Utils::now(); $qb = $this->em->createQueryBuilder(); $qb @@ -63,6 +65,10 @@ protected function getContestQueryBuilder(bool $onlyActive = false): QueryBuilde } else { $qb->andWhere('c.public = 1'); } + if ($filterBeforeContest) { + $qb->andWhere('c.starttime <= :now') + ->setParameter('now', $now); + } } return $qb; @@ -77,7 +83,10 @@ protected function getContestId(Request $request): int throw new BadRequestHttpException('cid parameter missing'); } - $qb = $this->getContestQueryBuilder($request->query->getBoolean('onlyActive', false)); + $qb = $this->getContestQueryBuilder( + onlyActive: $request->query->getBoolean('onlyActive', false), + filterBeforeContest: false + ); $qb ->andWhere(sprintf('c.%s = :cid', $this->getContestIdField())) ->setParameter('cid', $request->attributes->get('cid')); diff --git a/webapp/src/Controller/API/ContestController.php b/webapp/src/Controller/API/ContestController.php index 317d49cdcb..b0f4ce8ceb 100644 --- a/webapp/src/Controller/API/ContestController.php +++ b/webapp/src/Controller/API/ContestController.php @@ -179,7 +179,7 @@ public function singleAction(Request $request, string $cid): Response public function bannerAction(Request $request, string $cid): Response { /** @var Contest|null $contest */ - $contest = $this->getQueryBuilder($request) + $contest = $this->getQueryBuilder($request, filterBeforeContest: false) ->andWhere(sprintf('%s = :id', $this->getIdField())) ->setParameter('id', $cid) ->getQuery() @@ -934,10 +934,10 @@ public function samplesDataZipAction(Request $request): Response return $this->dj->getSamplesZipForContest($contest); } - protected function getQueryBuilder(Request $request): QueryBuilder + protected function getQueryBuilder(Request $request, bool $filterBeforeContest = true): QueryBuilder { try { - return $this->getContestQueryBuilder($request->query->getBoolean('onlyActive', false)); + return $this->getContestQueryBuilder($request->query->getBoolean('onlyActive', false), $filterBeforeContest); } catch (TypeError) { throw new BadRequestHttpException('\'onlyActive\' must be a boolean.'); } @@ -954,7 +954,7 @@ protected function getIdField(): string */ protected function getContestWithId(Request $request, string $id): Contest { - $queryBuilder = $this->getQueryBuilder($request) + $queryBuilder = $this->getQueryBuilder($request, filterBeforeContest: false) ->andWhere(sprintf('%s = :id', $this->getIdField())) ->setParameter('id', $id); @@ -971,7 +971,7 @@ protected function getContestWithId(Request $request, string $id): Contest private function getContestAndCheckIfLocked(Request $request, string $cid): Contest { /** @var Contest|null $contest */ - $contest = $this->getQueryBuilder($request) + $contest = $this->getQueryBuilder($request, filterBeforeContest: false) ->andWhere(sprintf('%s = :id', $this->getIdField())) ->setParameter('id', $cid) ->getQuery() From 5bc3b34cf49d90dcbd36a85d776585a0ab223513 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Wed, 9 Jul 2025 10:51:43 +0200 Subject: [PATCH 30/30] Release 8.3.2 --- ChangeLog | 4 ++++ README.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ccd133df9b..841b02c982 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ DOMjudge Programming Contest Judging System +Version 8.3.2 - 9 July 2025 +--------------------------- + - Expose samples/problemset after the contest start + Version 8.3.1 - 13 September 2024 --------------------------------- - Create autoload_runtime.php as normal user to prevent a composer warning. diff --git a/README.md b/README.md index eaa23881ee..3361eb3ffc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ DOMjudge [![Coverity Scan Status](https://img.shields.io/coverity/scan/671.svg)](https://scan.coverity.com/projects/domjudge) [![CodeQL alerts](https://github.com/DOMjudge/domjudge/actions/workflows/codeql-analysis.yml/badge.svg?branch=main&event=push)](https://github.com/DOMjudge/domjudge/actions/workflows/codeql-analysis.yml) -This is the Programming Contest Jury System "DOMjudge" version 8.3.1 +This is the Programming Contest Jury System "DOMjudge" version 8.3.2 DOMjudge is a system for running a programming contest, like the ICPC regional and world championship programming contests. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy