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: 3 additions & 7 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use App\Validators\Password;
use CDash\Database;
use CDash\Model\Build;
use CDash\Model\BuildConfigure;
use CDash\Model\Project;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\JsonResponse;
Expand Down Expand Up @@ -253,12 +252,9 @@ private function ReportLastBuild(string $type, int $projectid, int $siteid, stri
$response['datelink'] = 'index.php?project=' . urlencode($projectname) . '&date=' . $date;

// Configure
$BuildConfigure = new BuildConfigure();
$BuildConfigure->BuildId = $buildid;
$configure_row = $BuildConfigure->GetConfigureForBuild();
if ($configure_row) {
$response['configure'] = $configure_row['status'];
if ($configure_row['status'] != 0) {
if ($build->configure()->exists()) {
$response['configure'] = $build->configure->status;
if ($build->configure->status !== 0) {
$response['configureclass'] = 'error';
} else {
$response['configureclass'] = 'normal';
Expand Down
43 changes: 13 additions & 30 deletions app/cdash/app/Model/BuildConfigure.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use CDash\Database;
use Exception;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use PDO;

Expand Down Expand Up @@ -202,31 +201,21 @@ public function Insert()
return false;
}

DB::beginTransaction();
$new_configure_inserted = false;
if (!$this->ExistsByCrc32()) {
// No such configure exists yet, insert a new row.
$stmt = $this->PDO->prepare('
INSERT INTO configure (command, log, status, crc32)
VALUES (:command, :log, :status, :crc32)');
$stmt->bindParam(':command', $this->Command);
$stmt->bindParam(':log', $this->Log);
$stmt->bindParam(':status', $this->Status);
$stmt->bindParam(':crc32', $this->Crc32);
try {
if ($stmt->execute()) {
$new_configure_inserted = true;
$this->Id = DB::getPdo()->lastInsertId();
} else {
$error_info = $stmt->errorInfo();
$error = $error_info[2];
throw new Exception($error);
}
$this->Id = EloquentConfigure::create([
'command' => $this->Command,
'log' => $this->Log,
'status' => $this->Status,
'crc32' => $this->Crc32,
])->id;
$new_configure_inserted = true;
} catch (Exception $e) {
// This error might be due to a unique constraint violation.
// Query again to see if this configure was created since
// the last time we checked.
DB::rollBack();
if ($this->ExistsByCrc32()) {
return true;
} else {
Expand All @@ -237,19 +226,13 @@ public function Insert()
}

// Insert a new build2configure row for this build.
$stmt = $this->PDO->prepare('
INSERT INTO build2configure (buildid, configureid, starttime, endtime)
VALUES (:buildid, :configureid, :starttime, :endtime)');
$stmt->bindParam(':buildid', $this->BuildId);
$stmt->bindParam(':configureid', $this->Id);
$stmt->bindParam(':starttime', $this->StartTime);
$stmt->bindParam(':endtime', $this->EndTime);
if (!pdo_execute($stmt)) {
DB::rollBack();
return false;
}
EloquentBuildConfigure::create([
'buildid' => $this->BuildId,
'configureid' => $this->Id,
'starttime' => $this->StartTime,
'endtime' => $this->EndTime,
]);

DB::commit();
$this->InsertLabelAssociations();
return $new_configure_inserted;
}
Expand Down
4 changes: 0 additions & 4 deletions app/cdash/tests/test_buildconfigure.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public function testBuildConfigure(): void
$this->fail('configure->Insert returned true');
}

if (!$configure->GetConfigureForBuild()) {
$this->fail('configure->GetConfigureForBuild returned false');
}

if ($configure->Delete()) {
$this->fail('configure->Delete returned true');
}
Expand Down
20 changes: 4 additions & 16 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2584,8 +2584,8 @@ parameters:
path: app/Http/Controllers/UserController.php

-
rawMessage: Cannot access offset 'status' on mixed.
identifier: offsetAccess.nonOffsetAccessible
rawMessage: Cannot access property $status on App\Models\Configure|null.
identifier: property.nonObject
count: 2
path: app/Http/Controllers/UserController.php

Expand All @@ -2607,12 +2607,6 @@ parameters:
count: 1
path: app/Http/Controllers/UserController.php

-
rawMessage: 'Loose comparison via "!=" is not allowed.'
identifier: notEqual.notAllowed
count: 1
path: app/Http/Controllers/UserController.php

-
rawMessage: 'Method App\Http\Controllers\UserController::ReportLastBuild() has parameter $nightlytime with no type specified.'
identifier: missingType.parameter
Expand All @@ -2634,7 +2628,7 @@ parameters:
-
rawMessage: 'Only booleans are allowed in an if condition, mixed given.'
identifier: if.condNotBoolean
count: 3
count: 2
path: app/Http/Controllers/UserController.php

-
Expand Down Expand Up @@ -9867,7 +9861,7 @@ parameters:
v2.5.0 01/22/2018
'''
identifier: function.deprecated
count: 3
count: 2
path: app/cdash/app/Model/BuildConfigure.php

-
Expand Down Expand Up @@ -20910,12 +20904,6 @@ parameters:
count: 1
path: app/cdash/tests/test_buildconfigure.php

-
rawMessage: 'Only booleans are allowed in a negated boolean, mixed given.'
identifier: booleanNot.exprNotBoolean
count: 1
path: app/cdash/tests/test_buildconfigure.php

-
rawMessage: 'Only booleans are allowed in a while condition, mixed given.'
identifier: while.condNotBoolean
Expand Down