Skip to content

Fix multiple bugs: TypeScript strict mode errors, PHP division by zero, null dereference, and logic issues - #5681

Open
itriedcoding wants to merge 1 commit into
pterodactyl:1.0-developfrom
itriedcoding:fix/multiple-bugs-and-type-errors
Open

Fix multiple bugs: TypeScript strict mode errors, PHP division by zero, null dereference, and logic issues#5681
itriedcoding wants to merge 1 commit into
pterodactyl:1.0-developfrom
itriedcoding:fix/multiple-bugs-and-type-errors

Conversation

@itriedcoding

Copy link
Copy Markdown

Summary

This PR fixes multiple bugs found through static analysis and code review across both the TypeScript frontend and PHP backend.

TypeScript Fixes (12 errors)

  • Added explicit event handler type annotations to fix all
    oImplicitAny errors in strict mode across: Checkbox, Modal, Switch, JavaVersionModalFeature, FileEditContainer, UploadButton, AllocationRow, VariableBox

PHP Fixes

High Severity:

  • NodeRepository: Fixed division by zero when $maxUsage is 0 (e.g., memory/disk with no overallocation and base value of 0)
  • NodeRepository: Changed join() to leftJoin() in getUsageStats and getUsageStatsRaw to prevent null dereference when a node has no servers
  • StartupModificationService: Fixed pass-by-reference variable reassignment bug where $server = ->forceFill(...) created a new local variable instead of updating the caller's $server, causing egg_id/nest_id changes to be lost

Medium Severity:

  • BuildModificationService: Initialized $freshlyAllocated = null before the conditional block to prevent undefined variable when �dd_allocations is empty but
    emove_allocations is not
  • ProcessScheduleService: Fixed $job->failed() being called twice when exception is not a DaemonConnectionException
  • AssignmentService: Added try/catch around transaction body to properly roll back on exception, preventing connection pool exhaustion

Low Severity:

  • Node model: Removed duplicate 'description' entry in $fillable array

…o, null dereference, and logic issues

- Fix 12 TypeScript noImplicitAny errors by adding explicit event handler types
- Fix division by zero in NodeRepository when node has no resource limits set
- Fix null dereference in NodeRepository getUsageStats when node has no servers
  by changing inner join to left join
- Fix pass-by-reference variable reassignment bug in StartupModificationService
  where egg_id/nest_id changes were lost
- Fix undefined  variable in BuildModificationService
- Fix duplicate 'description' entry in Node model
- Fix ->failed() being called twice in ProcessScheduleService
- Fix unhandled transaction rollback on exception in AssignmentService
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant