Skip to content
Merged
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
10 changes: 5 additions & 5 deletions app/cdash/app/Model/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Project
public $BugTrackerUrl;
public $BugTrackerNewIssueUrl;
public $BugTrackerType;
public $ImageId;
public ?int $ImageId = null;
public $Public;
public $CoverageThreshold;
public $TestingDataUrl;
Expand Down Expand Up @@ -146,7 +146,7 @@ public function Save(): bool
'testtimemaxstatus' => (int) $this->TestTimeMaxStatus,
'emailmaxitems' => (int) $this->EmailMaxItems,
'emailmaxchars' => (int) $this->EmailMaxChars,
'imageid' => $this->ImageId ?? 0,
'imageid' => $this->ImageId,
'ldapfilter' => $this->LdapFilter,
'banner' => $this->Banner,
]);
Expand Down Expand Up @@ -180,13 +180,13 @@ public function FindByName($name): bool
}

/** Get the logo id */
private function GetLogoId(): int
private function GetLogoId(): ?int
{
if (!$this->Filled) {
$this->Fill();
}

return $this->Id > 0 ? $this->ImageId : 0;
return $this->Id > 0 ? $this->ImageId : null;
}

/** Fill in all the information from the database */
Expand Down Expand Up @@ -297,7 +297,7 @@ public function AddLogo($contents, string $filetype)
$image->Extension = $filetype;

$imgid = $this->GetLogoId();
if ($imgid > 0) {
if ($imgid !== null) {
$image->Id = $imgid;
}

Expand Down
2 changes: 1 addition & 1 deletion app/cdash/include/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ function get_dashboard_JSON($projectname, $date, &$response): void
$response['public'] = $project->Public;
$response['previousdate'] = $previousdate;
$response['nextdate'] = $nextdate;
$response['logoid'] = $project->ImageId ?? 0;
$response['logoid'] = $project->ImageId;
$response['nightlytime'] = date('H:i T', strtotime($project_array['nightlytime']));
if (empty($project_array['homeurl'])) {
$response['home'] = 'index.php?project=' . urlencode($project_array['name']);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Database\Migrations\Migration;

return new class extends Migration {
public function up(): void
{
DB::statement('ALTER TABLE project ALTER COLUMN imageid DROP NOT NULL');
DB::statement('ALTER TABLE project ALTER COLUMN imageid DROP DEFAULT');
DB::update('
UPDATE project
SET imageid=NULL
WHERE imageid=0 OR NOT EXISTS (
SELECT * FROM image WHERE image.id=project.imageid
)');
DB::statement('ALTER TABLE project ADD FOREIGN KEY (imageid) REFERENCES image(id) ON DELETE SET NULL');
}

public function down(): void
{
}
};
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11559,12 +11559,6 @@ parameters:
count: 1
path: app/cdash/app/Model/Project.php

-
rawMessage: Property CDash\Model\Project::$ImageId has no type specified.
identifier: missingType.property
count: 1
path: app/cdash/app/Model/Project.php

-
rawMessage: Property CDash\Model\Project::$Name has no type specified.
identifier: missingType.property
Expand Down
6 changes: 3 additions & 3 deletions resources/js/vue/components/EditProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,11 @@
<div valign="top">
<strong>Current logo:</strong>
</div>
<span v-if="cdash.project.ImageId == 0">
<span v-if="cdash.project.ImageId == null">
[none]
</span>
<img
v-if="cdash.project.ImageId != 0"
v-if="cdash.project.ImageId != null"
id="projectlogo"
border="0"
:alt="cdash.project_name"
Expand Down Expand Up @@ -2356,7 +2356,7 @@ export default {
this.$axios
.post('/api/v1/project.php', data, config)
.then(response => {
if (response.data.imageid > 0) {
if (response.data.imageid !== null) {
this.previewLogo = null;
this.uploadedLogo = null;
// Use a decache to force the logo to refresh even if the imageid didn't change.
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
href="{{ url('/')}}"
@endif
>
@if(isset($project) && $logoid > 0)
@if(isset($project) && $logoid !== null)
<img id="projectlogo" height="50px" alt="" src="{{ url('/image/' . $logoid) }}" />
@else
<img id="projectlogo" height="50px" alt="" src="{{ asset('img/cdash.svg') }}" />
Expand Down
2 changes: 1 addition & 1 deletion tests/Spec/edit-project.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ beforeEach(() => {
ErrorsFilter: '',
Filled: true,
Id: 1,
ImageId: 0,
ImageId: 1,
MaxUploadQuota: 10,
Name: 'MyTestingProject',
NightlyTime: '01:00:00 UTC',
Expand Down