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
2 changes: 1 addition & 1 deletion app/GraphQL/Mutations/RemoveProjectUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __invoke(null $_, array $args): self
$userToRemove->id !== $user->id
&& $user->cannot('removeUser', $project)
)
|| !$project->users()->where('id', $userToRemove->id)->exists()
|| !$project->users()->whereKey($userToRemove->id)->exists()
) {
throw new GraphQLMutationException('This action is unauthorized.');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProjectInvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __invoke(Request $request, int $projectId, int $invitationId): R
abort(401, 'Membership is managed by LDAP for this project.');
}

if ($user->projects()->where('id', $user_invite->project_id)->exists()) {
if ($user->projects()->whereKey($user_invite->project_id)->exists()) {
$user_invite->deleteOrFail();
abort(401, 'You are already registered for this project.');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/TestDetailsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function apiTestDetails(): JsonResponse|StreamedResponse
abort(400, 'A valid test was not specified.');
}

$buildtest = Test::where('id', '=', $buildtestid)->first();
$buildtest = Test::whereKey($buildtestid)->first();
if ($buildtest === null) {
// Create a dummy project object to prevent information leakage between different error cases
$project = new Project();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Submission/Handlers/BazelJSONHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ private function InitializeSubProjectBuild($subproject_name)
if (array_key_exists('', $this->Builds)) {
$this->ParentBuild = $this->Builds[''];
unset($this->Builds['']);
\App\Models\Build::where('id', $this->ParentBuild->Id)->update(['parentid' => Build::PARENT_BUILD]);
\App\Models\Build::whereKey($this->ParentBuild->Id)->update(['parentid' => Build::PARENT_BUILD]);
$this->ParentBuild->SetParentId(Build::PARENT_BUILD);
}

Expand Down
14 changes: 7 additions & 7 deletions app/Policies/ProjectPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function view(?User $user, Project $project): bool
}

// Private projects can only be viewed by members who are explicitly added.
if ($project->public === Project::ACCESS_PRIVATE && $project->users()->where('id', $user->id)->exists()) {
if ($project->public === Project::ACCESS_PRIVATE && $project->users()->whereKey($user->id)->exists()) {
return true;
}

Expand Down Expand Up @@ -68,7 +68,7 @@ public function update(User $user, Project $project): bool
}

// Users can edit projects they administer
if ($project->administrators()->where('id', $user->id)->exists()) {
if ($project->administrators()->whereKey($user->id)->exists()) {
return true;
}

Expand All @@ -83,7 +83,7 @@ public function changeUserRole(User $currentUser, Project $project, User $userTo
}

// Can't change the role for users who aren't in the project...
if (!$project->users()->where('id', $userToChange->id)->exists()) {
if (!$project->users()->whereKey($userToChange->id)->exists()) {
return false;
}

Expand Down Expand Up @@ -133,12 +133,12 @@ public function join(User $currentUser, Project $project): bool
return false;
}

return !$project->users()->where('id', $currentUser->id)->exists();
return !$project->users()->whereKey($currentUser->id)->exists();
}

public function leave(User $currentUser, Project $project): bool
{
return !$this->isLdapControlledMembership($project) && $project->users()->where('id', $currentUser->id)->exists();
return !$this->isLdapControlledMembership($project) && $project->users()->whereKey($currentUser->id)->exists();
}

public function createPinnedTestMeasurement(User $currentUser, Project $project): bool
Expand Down Expand Up @@ -168,12 +168,12 @@ public function deleteRepository(User $currentUser, Project $project): bool

public function createAuthToken(User $currentUser, Project $project): bool
{
return $currentUser->admin || $project->users()->where('id', $currentUser->id)->exists();
return $currentUser->admin || $project->users()->whereKey($currentUser->id)->exists();
}

public function createCoverageDiff(User $user, Project $project): bool
{
return $user->admin || $project->users()->where('id', $user->id)->exists();
return $user->admin || $project->users()->whereKey($user->id)->exists();
}

private function isLdapControlledMembership(Project $project): bool
Expand Down
20 changes: 10 additions & 10 deletions app/cdash/app/Model/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function UpdateEndTime(string $end_time): bool
return false;
}

return EloquentBuild::where('id', $this->Id)->update([
return EloquentBuild::whereKey($this->Id)->update([
'endtime' => $end_time,
]) > 0;
}
Expand Down Expand Up @@ -684,7 +684,7 @@ public function Exists(): bool
return false;
}

return EloquentBuild::where('id', $this->Id)->exists();
return EloquentBuild::whereKey($this->Id)->exists();
}

public function Save()
Expand Down Expand Up @@ -811,7 +811,7 @@ public function UpdateTestNumbers(int $numberTestsPassed, int $numberTestsFailed
$this->SetParentId($this->LookupParentBuildId());
$this->UpdateParentTestNumbers($newFailed, $newNotRun, $newPassed);

EloquentBuild::where('id', $this->Id)->update([
EloquentBuild::whereKey($this->Id)->update([
'testnotrun' => $numberTestsNotRun,
'testfailed' => $numberTestsFailed,
'testpassed' => $numberTestsPassed,
Expand Down Expand Up @@ -1225,7 +1225,7 @@ public function ComputeTestTiming(): bool
}
}

return EloquentBuild::where('id', $this->Id)->update([
return EloquentBuild::whereKey($this->Id)->update([
'testtimestatusfailed' => $testtimestatusfailed,
]) > 0;
}
Expand Down Expand Up @@ -1656,7 +1656,7 @@ public function SetNumberOfConfigureWarnings(int $numWarnings): void
return;
}

EloquentBuild::where('id', (int) $this->Id)->update([
EloquentBuild::whereKey((int) $this->Id)->update([
'configurewarnings' => $numWarnings,
]);
}
Expand All @@ -1668,7 +1668,7 @@ public function SetNumberOfConfigureErrors(int $numErrors): void
return;
}

EloquentBuild::where('id', (int) $this->Id)->update([
EloquentBuild::whereKey((int) $this->Id)->update([
'configureerrors' => $numErrors,
]);

Expand Down Expand Up @@ -1762,7 +1762,7 @@ private function UpdateDuration(string $field, int $duration, bool $update_paren

DB::transaction(function () use ($field, $duration, $update_parent): void {
// Update duration of specified step for this build.
EloquentBuild::where('id', $this->Id)
EloquentBuild::whereKey($this->Id)
->increment("{$field}duration", $duration);

if (!$update_parent) {
Expand All @@ -1773,7 +1773,7 @@ private function UpdateDuration(string $field, int $duration, bool $update_paren
$this->SetParentId($this->LookupParentBuildId());
if ($this->ParentId > 0) {
// Update duration of specified step for this build.
EloquentBuild::where('id', $this->ParentId)
EloquentBuild::whereKey($this->ParentId)
->increment("{$field}duration", $duration);
}
}, 5);
Expand Down Expand Up @@ -1825,7 +1825,7 @@ public function GetDone(): bool
/** Set (or unset) the done bit in the database for this build. */
public function MarkAsDone(bool $done): void
{
EloquentBuild::where('id', $this->Id)->update([
EloquentBuild::whereKey($this->Id)->update([
'done' => $done,
]);
}
Expand Down Expand Up @@ -2152,7 +2152,7 @@ public function AssignToGroup(): void

// Add the subproject relationship if necessary.
if ($this->SubProjectId) {
EloquentBuild::where('id', $this->Id)->update(['subprojectid' => $this->SubProjectId]);
EloquentBuild::whereKey($this->Id)->update(['subprojectid' => $this->SubProjectId]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/cdash/app/Model/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function GetData(): void
/** Check if exists */
private function Exists(): bool
{
$model = EloquentImage::where('id', (int) $this->Id)
$model = EloquentImage::whereKey((int) $this->Id)
->orWhere('checksum', $this->Checksum)
->first();
if ($model === null) {
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/app/Model/SubProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public function AddDependency(int $subprojectid): void
// If the dependency already exists, exit early
$dependency_exists = EloquentSubProject::findOrFail($this->Id)
->children()
->where('id', $subprojectid)
->whereKey($subprojectid)
->exists();
if ($dependency_exists) {
return;
Expand Down
2 changes: 1 addition & 1 deletion app/cdash/app/Model/SubProjectGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function Save(): void
// Make sure there's only one default group per project.
if ($this->IsDefault) {
EloquentSubProjectGroup::where('projectid', $this->ProjectId)
->where('id', '!=', $this->Id)
->whereKeyNot($this->Id)
->update([
'is_default' => 0,
]);
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 @@ -16,7 +16,7 @@

$currentDateString = Carbon::parse($eloquentProject->builds()->max('starttime'))->toDateString();

$userInProject = auth()->user() !== null && $eloquentProject->users()->where('id', auth()->user()->id)->exists();
$userInProject = auth()->user() !== null && $eloquentProject->users()->whereKey(auth()->user()->id)->exists();
}

$showHeaderNav = isset($build);
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
Route::get('/testDetails.php', function (Request $request) {
$buildid = $request->query('build');
$testid = $request->query('test');
$buildtest = Test::where('buildid', $buildid)->where('id', $testid)->first();
$buildtest = Test::where('buildid', $buildid)->whereKey($testid)->first();
if ($buildtest !== null) {
return redirect("/tests/{$buildtest->id}", 301);
}
Expand Down