From 9ccc07cdb51d2796687b23eaf6eed9b472201e50 Mon Sep 17 00:00:00 2001 From: William Allen Date: Wed, 12 Aug 2026 18:43:47 -0400 Subject: [PATCH] Fix global admin vs project admin index page bug #3877 introduced a bug where the build management controls are visible to global administrators, but not project administrators. This PR fixes the issue. --- app/cdash/include/common.php | 8 ++++++-- phpstan-baseline.neon | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/cdash/include/common.php b/app/cdash/include/common.php index 6f3379f32c..85bdd93fd6 100644 --- a/app/cdash/include/common.php +++ b/app/cdash/include/common.php @@ -610,8 +610,12 @@ function get_dashboard_JSON($projectname, $date, &$response): void $userid = Auth::id(); if ($userid) { $project = App\Models\Project::findOrFail((int) $project->Id); - $response['projectrole'] = $project->users()->withPivot('role')->find((int) $userid)->pivot->role ?? ProjectRole::USER; - if ($response['projectrole'] === ProjectRole::ADMINISTRATOR) { + $projectrole = $project->users()->withPivot('role')->find((int) $userid)->pivot->role ?? ProjectRole::USER; + if (!$projectrole instanceof ProjectRole) { + $projectrole = ProjectRole::from($projectrole); + } + $response['projectrole'] = $projectrole->value; + if ($projectrole === ProjectRole::ADMINISTRATOR) { $response['user']['admin'] = 1; } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d2ab888878..6c58b77e1d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11895,6 +11895,18 @@ parameters: count: 1 path: app/cdash/include/common.php + - + rawMessage: 'Function get_dashboard_JSON() throws checked exception TypeError but it''s missing from the PHPDoc @throws tag.' + identifier: missingType.checkedException + count: 1 + path: app/cdash/include/common.php + + - + rawMessage: 'Function get_dashboard_JSON() throws checked exception ValueError but it''s missing from the PHPDoc @throws tag.' + identifier: missingType.checkedException + count: 1 + path: app/cdash/include/common.php + - rawMessage: 'Function get_dates() has parameter $date with no type specified.' identifier: missingType.parameter