Skip to content

Monthly Shift: July 2026 - #2433

Merged
lancepioch merged 10 commits into
mainfrom
shift-2026-07
Jul 9, 2026
Merged

Monthly Shift: July 2026#2433
lancepioch merged 10 commits into
mainfrom
shift-2026-07

Conversation

@lancepioch

Copy link
Copy Markdown
Member

This is an automated pull request included with your Shifty Plan. It contains curated refactors to keep your Laravel application aligned with the latest conventions and features.

This month focuses on a set of curated refactors to keep your Laravel apps modernized and your code streamlined. These are a subset of the refactors performed by the Laravel Fixer, which is included with your subscription.

Before merging, you should:

  • Checkout the shift-2026-07 branch
  • Review all pull request comments for additional changes
  • Test your application

If you do not wish to adopt these refactors, you may simply close this pull request and delete its branch.

PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
Laravel offers many helper functions, including: `view()`, `response()`, `redirect()`, `config()`, and more.

Review the [Helpers][1] documentation for more details.

[1]: https://laravel.com/docs/helpers
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3710236e-1311-4e54-b5d0-6db96cec71b9

📥 Commits

Reviewing files that changed from the base of the PR and between 52542d6 and 3261791.

📒 Files selected for processing (5)
  • app/Http/Controllers/Api/Client/Servers/BackupController.php
  • app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php
  • app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php
  • app/Services/Backups/DeleteBackupService.php
  • app/Services/Backups/InitiateBackupService.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php
  • app/Services/Backups/InitiateBackupService.php

📝 Walkthrough

Walkthrough

This PR performs a broad codebase-wide refactor with no functional changes: explicit if/throw validation and authorization blocks in controllers, middleware, requests, models, services, repositories, and jobs are converted to Laravel's throw_if/throw_unless/abort_if/abort_unless helpers, and the Carbon import is migrated from Carbon\Carbon to Illuminate\Support\Carbon across the codebase. Two Filament pages also switch activity log ordering from orderBy('timestamp', 'desc') to orderByDesc('timestamp').

Changes

Guard Clause Refactor

Layer / File(s) Summary
Console commands and migration validation guards
app/Console/Commands/Egg/CheckEggUpdatesCommand.php, app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php, database/migrations/2024_07_19_130942_create_permission_tables.php
File-extension, HTTP response, prune-age, and permission-table config validations converted to throw_if.
Extensions and Filament component guards
app/Extensions/Captcha/Schemas/Turnstile/TurnstileSchema.php, app/Filament/Components/Actions/UploadIcon.php, app/Filament/Components/Forms/Fields/MonacoEditor.php, app/Filament/Server/Resources/Files/Pages/ListFiles.php, app/Filament/Server/Widgets/ServerConsole.php, app/Filament/Admin/Resources/Plugins/PluginResource.php
Secret-key/domain, icon URL, editor theme, folder-permission, token, and plugin-existence checks converted to guard helpers.
Activity log ordering
app/Filament/Admin/Resources/Users/UserResource.php, app/Filament/Pages/Auth/EditProfile.php
Activity relationship queries switch timestamp sort to orderByDesc.
Application API controllers
app/Http/Controllers/Api/Application/Mounts/MountController.php, .../Plugins/PluginController.php, .../Roles/RoleController.php
Existence, status, and root-admin checks converted to throw_if/throw_unless.
Client API controllers
app/Http/Controllers/Api/Client/AccountController.php, ApiKeyController.php, Servers/BackupController.php, CommandController.php, NetworkAllocationController.php, ScheduleController.php, ScheduleTaskController.php, SettingsController.php, StartupController.php, WebsocketController.php
Throttling, authorization, existence, and limit checks converted to guard helpers.
Remote/daemon controllers
app/Http/Controllers/Api/Remote/Backups/*, Servers/ServerContainersController.php, ServerDetailsController.php, ServerInstallController.php, ServerTransferController.php, SftpAuthenticationController.php
Node authorization and validation checks converted to guard helpers.
Middleware guards
app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php, Api/Client/RequireClientApiKey.php, Api/Client/Server/AuthenticateServerAccess.php, ResourceBelongsToServer.php, Api/Daemon/DaemonAuthenticate.php, RequireTwoFactorAuthentication.php
Authentication/authorization and ownership checks converted to guard helpers.
Form request guards
app/Http/Requests/Api/Application/ApplicationApiRequest.php, Api/Client/Account/*, Api/Client/Servers/Schedules/ViewScheduleRequest.php, Subusers/SubuserRequest.php
ACL, password, and ownership validation converted to throw_if/throw_unless.
Jobs, installer steps, and models
app/Jobs/Schedule/RunTaskJob.php, app/Livewire/Installer/Steps/CacheStep.php, DatabaseStep.php, app/Models/ActivityLog.php, Filters/MultiFieldServerFilter.php, Plugin.php, Server.php, Traits/HasIcon.php, WebhookConfiguration.php
Task-schema, connection, pruning, plugin, server-state, and icon-write checks converted to guard helpers; sequence ordering simplified.
Daemon repositories
app/Repositories/Daemon/DaemonFileRepository.php, DaemonRepository.php, DaemonSystemRepository.php
HTTP response and token validation converted to guard helpers.
Allocation, backup, and database services
app/Services/Allocations/AssignmentService.php, FindAssignableAllocationService.php, Backups/DeleteBackupService.php, InitiateBackupService.php, Databases/DatabaseManagementService.php, DeployServerDatabaseService.php, Deployment/AllocationSelectionService.php
Range, limit, and eligibility checks converted to guard helpers.
Egg, schedule, server, and plugin services
app/Services/Eggs/Sharing/EggImporterService.php, Variables/*, Helpers/PluginService.php, Nodes/*, Schedules/*, Servers/*, Ssh/KeyCreationService.php, Subusers/SubuserCreationService.php, app/Traits/HasValidation.php, Transformers/Api/Client/EggVariableTransformer.php
Upload, reserved-name, class-existence, and validation checks converted to guard helpers.
Test helper guards
tests/Traits/Http/MocksMiddlewareClosure.php, RequestMockHelpers.php, tests/Unit/Console/Commands/Egg/NormalizerEggCommandTest.php
Request-mock and file/directory setup checks converted to guard helpers.

Carbon Import Migration

Layer / File(s) Summary
Application-layer imports
app/Checks/ScheduleCheck.php, app/Console/Commands/Egg/NormalizeEggCommand.php, Maintenance/CleanServiceBackupFilesCommand.php, app/Filament/Admin/Pages/Health.php, Server/Resources/Schedules/ScheduleResource.php, Server/Widgets/ServerCpuChart.php, ServerMemoryChart.php, ServerNetworkChart.php, app/Helpers/Utilities.php, Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php, ScheduleController.php, Api/Remote/ActivityProcessingController.php, app/Services/Eggs/Sharing/EggExporterService.php, app/Transformers/Api/Client/FileObjectTransformer.php
Carbon import switched from Carbon\Carbon to Illuminate\Support\Carbon across controllers, widgets, and services.
Factories, migrations, and tests
database/Factories/*, database/migrations/*, tests/TestCase.php, tests/Integration/Jobs/Schedule/RunTaskJobTest.php, tests/Unit/Console/Commands/Egg/NormalizerEggCommandTest.php
Carbon import switched to Illuminate\Support\Carbon in factories, migrations, and test base classes.

Possibly related PRs

  • pelican-dev/panel#1579: Touches the same remote API controllers (ServerContainersController::status, ServerTransferController::failure/success).
  • pelican-dev/panel#2146: Touches PluginController action guards that align with this PR's throw_if/throw_unless refactor.
  • pelican-dev/panel#1911: Touches the same schedule-task execution path in RunTaskJob.php.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly matches the automated monthly refactor bundle.
Description check ✅ Passed The description is directly related to the automated Laravel refactor changeset and review instructions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
app/Traits/Services/ValidatesValidationRules.php (1)

26-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Exception message relies on by-reference side effect via argument order.

$matches is populated as a side effect of the first throw_if argument (preg_match) and consumed by the second argument (new BadValidationRuleException(...)). This is correct only because PHP evaluates call arguments left-to-right; it's a non-obvious coupling that could silently break for future readers/refactors of this line.

Consider extracting the match result into a local step to make the dependency explicit:

♻️ Suggested clarification
         } catch (BadMethodCallException $exception) {
             $matches = [];
-            throw_if(preg_match('/Method \[(.+)\] does not exist\./', $exception->getMessage(), $matches), new BadValidationRuleException(trans('exceptions.variables.bad_validation_rule', ['rule' => Str::snake(str_replace('validate', '', array_get($matches, 1, 'unknownRule')))]), $exception));
+            $matched = preg_match('/Method \[(.+)\] does not exist\./', $exception->getMessage(), $matches);
+            throw_if($matched, new BadValidationRuleException(trans('exceptions.variables.bad_validation_rule', ['rule' => Str::snake(str_replace('validate', '', array_get($matches, 1, 'unknownRule')))]), $exception));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/Traits/Services/ValidatesValidationRules.php` around lines 26 - 30, The
BadMethodCallException handling in ValidatesValidationRules currently depends on
preg_match populating $matches as a side effect inside throw_if, which makes the
BadValidationRuleException construction order-sensitive and hard to follow.
Refactor this block by extracting the regex match result into an explicit local
step before creating the exception, then use that extracted rule name when
building the translated message. Keep the logic in the catch block and the
existing BadValidationRuleException/throw_if behavior, but make the dependency
between the match and the exception message explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Models/File.php`:
- Line 210: The `throw_if` call in `File::...` is eagerly evaluating `new
Exception($contents['error'])`, which reads `$contents['error']` even on the
normal path and causes an undefined-array-key warning. Replace this with a
conditional that only constructs the exception when `isset($contents['error'])`
is true, keeping the access to `$contents['error']` inside that guarded branch
so the non-error path never touches the missing key.

In `@app/Models/Server.php`:
- Around line 430-433: Avoid eager construction of ServerStateConflictException
in validateTransferState(), since throw_if() still builds it even when the guard
passes and that triggers an unnecessary node lazy-load. Update
validateTransferState() to check the conflict condition first and only
instantiate ServerStateConflictException when the transfer state is actually
invalid; keep validateCurrentState() as-is because it already touches
node/transfer.

In `@app/Services/Deployment/AllocationSelectionService.php`:
- Around line 66-68: The port-range guard in AllocationSelectionService is using
a difference check that excludes the end value, so it can թույլ through an
inclusive range that exceeds AssignmentService::PORT_RANGE_LIMIT. Update the
validation around the range parsing in the allocation selection logic to compare
the inclusive span (end minus start plus one) instead of abs($matches[2] -
$matches[1]), and keep the existing DisplayException/too_many_ports behavior
when the inclusive count is over the limit.

---

Nitpick comments:
In `@app/Traits/Services/ValidatesValidationRules.php`:
- Around line 26-30: The BadMethodCallException handling in
ValidatesValidationRules currently depends on preg_match populating $matches as
a side effect inside throw_if, which makes the BadValidationRuleException
construction order-sensitive and hard to follow. Refactor this block by
extracting the regex match result into an explicit local step before creating
the exception, then use that extracted rule name when building the translated
message. Keep the logic in the catch block and the existing
BadValidationRuleException/throw_if behavior, but make the dependency between
the match and the exception message explicit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 77d276a1-4a46-407d-a02c-aed14bd3f0a1

📥 Commits

Reviewing files that changed from the base of the PR and between 614153a and c6ccf07.

📒 Files selected for processing (108)
  • app/Checks/ScheduleCheck.php
  • app/Console/Commands/Egg/CheckEggUpdatesCommand.php
  • app/Console/Commands/Egg/NormalizeEggCommand.php
  • app/Console/Commands/Maintenance/CleanServiceBackupFilesCommand.php
  • app/Console/Commands/Maintenance/PruneOrphanedBackupsCommand.php
  • app/Extensions/Backups/BackupManager.php
  • app/Extensions/Captcha/Schemas/Turnstile/TurnstileSchema.php
  • app/Filament/Admin/Pages/Health.php
  • app/Filament/Admin/Resources/Nodes/Pages/EditNode.php
  • app/Filament/Admin/Resources/Plugins/PluginResource.php
  • app/Filament/Admin/Resources/Users/UserResource.php
  • app/Filament/Components/Actions/UploadIcon.php
  • app/Filament/Components/Forms/Fields/MonacoEditor.php
  • app/Filament/Pages/Auth/EditProfile.php
  • app/Filament/Server/Resources/Files/Pages/ListFiles.php
  • app/Filament/Server/Resources/Schedules/ScheduleResource.php
  • app/Filament/Server/Widgets/ServerConsole.php
  • app/Filament/Server/Widgets/ServerCpuChart.php
  • app/Filament/Server/Widgets/ServerMemoryChart.php
  • app/Filament/Server/Widgets/ServerNetworkChart.php
  • app/Helpers/Utilities.php
  • app/Http/Controllers/Api/Application/Mounts/MountController.php
  • app/Http/Controllers/Api/Application/Plugins/PluginController.php
  • app/Http/Controllers/Api/Application/Roles/RoleController.php
  • app/Http/Controllers/Api/Client/AccountController.php
  • app/Http/Controllers/Api/Client/ApiKeyController.php
  • app/Http/Controllers/Api/Client/Servers/BackupController.php
  • app/Http/Controllers/Api/Client/Servers/CommandController.php
  • app/Http/Controllers/Api/Client/Servers/NetworkAllocationController.php
  • app/Http/Controllers/Api/Client/Servers/ResourceUtilizationController.php
  • app/Http/Controllers/Api/Client/Servers/ScheduleController.php
  • app/Http/Controllers/Api/Client/Servers/ScheduleTaskController.php
  • app/Http/Controllers/Api/Client/Servers/SettingsController.php
  • app/Http/Controllers/Api/Client/Servers/StartupController.php
  • app/Http/Controllers/Api/Client/Servers/WebsocketController.php
  • app/Http/Controllers/Api/Remote/ActivityProcessingController.php
  • app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php
  • app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php
  • app/Http/Controllers/Api/Remote/Servers/ServerContainersController.php
  • app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php
  • app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php
  • app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php
  • app/Http/Controllers/Api/Remote/SftpAuthenticationController.php
  • app/Http/Middleware/Api/Application/AuthenticateApplicationUser.php
  • app/Http/Middleware/Api/Client/RequireClientApiKey.php
  • app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php
  • app/Http/Middleware/Api/Client/Server/ResourceBelongsToServer.php
  • app/Http/Middleware/Api/Daemon/DaemonAuthenticate.php
  • app/Http/Middleware/RequireTwoFactorAuthentication.php
  • app/Http/Requests/Api/Application/ApplicationApiRequest.php
  • app/Http/Requests/Api/Client/Account/StoreSSHKeyRequest.php
  • app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php
  • app/Http/Requests/Api/Client/Account/UpdatePasswordRequest.php
  • app/Http/Requests/Api/Client/Account/UpdateUsernameRequest.php
  • app/Http/Requests/Api/Client/Servers/Schedules/ViewScheduleRequest.php
  • app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php
  • app/Jobs/Schedule/RunTaskJob.php
  • app/Livewire/Installer/Steps/CacheStep.php
  • app/Livewire/Installer/Steps/DatabaseStep.php
  • app/Models/ActivityLog.php
  • app/Models/File.php
  • app/Models/Filters/MultiFieldServerFilter.php
  • app/Models/Plugin.php
  • app/Models/Server.php
  • app/Models/Traits/HasIcon.php
  • app/Models/WebhookConfiguration.php
  • app/Repositories/Daemon/DaemonFileRepository.php
  • app/Repositories/Daemon/DaemonRepository.php
  • app/Repositories/Daemon/DaemonSystemRepository.php
  • app/Services/Allocations/AssignmentService.php
  • app/Services/Allocations/FindAssignableAllocationService.php
  • app/Services/Backups/DeleteBackupService.php
  • app/Services/Backups/InitiateBackupService.php
  • app/Services/Databases/DatabaseManagementService.php
  • app/Services/Databases/DeployServerDatabaseService.php
  • app/Services/Deployment/AllocationSelectionService.php
  • app/Services/Eggs/Sharing/EggExporterService.php
  • app/Services/Eggs/Sharing/EggImporterService.php
  • app/Services/Eggs/Variables/VariableCreationService.php
  • app/Services/Eggs/Variables/VariableUpdateService.php
  • app/Services/Helpers/PluginService.php
  • app/Services/Nodes/NodeDeletionService.php
  • app/Services/Nodes/NodeUpdateService.php
  • app/Services/Schedules/ProcessScheduleService.php
  • app/Services/Schedules/Sharing/ScheduleImporterService.php
  • app/Services/Servers/ServerCreationService.php
  • app/Services/Servers/ToggleInstallService.php
  • app/Services/Servers/VariableValidatorService.php
  • app/Services/Ssh/KeyCreationService.php
  • app/Services/Subusers/SubuserCreationService.php
  • app/Traits/HasValidation.php
  • app/Traits/Services/ValidatesValidationRules.php
  • app/Transformers/Api/Client/EggVariableTransformer.php
  • app/Transformers/Api/Client/FileObjectTransformer.php
  • database/Factories/ApiKeyFactory.php
  • database/Factories/DatabaseFactory.php
  • database/Factories/ServerFactory.php
  • database/Factories/UserFactory.php
  • database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php
  • database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php
  • database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php
  • database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php
  • database/migrations/2024_07_19_130942_create_permission_tables.php
  • tests/Integration/Jobs/Schedule/RunTaskJobTest.php
  • tests/TestCase.php
  • tests/Traits/Http/MocksMiddlewareClosure.php
  • tests/Traits/Http/RequestMockHelpers.php
  • tests/Unit/Console/Commands/Egg/NormalizerEggCommandTest.php

Comment thread app/Models/File.php Outdated
Comment thread app/Models/Server.php
Comment thread app/Services/Deployment/AllocationSelectionService.php Outdated
# Conflicts:
#	app/Extensions/Backups/BackupManager.php
#	app/Http/Controllers/Api/Client/Servers/BackupController.php
#	app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php
#	app/Services/Backups/DeleteBackupService.php
@lancepioch
lancepioch merged commit 4ff5adc into main Jul 9, 2026
16 checks passed
@lancepioch
lancepioch deleted the shift-2026-07 branch July 9, 2026 13:55
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants