Skip to content

Fix server limit for product upgrades/downgrades - #1356

Open
KroZen-Dev wants to merge 2 commits into
Ctrlpanel-gg:developmentfrom
KroZen-Dev:fix/server-upgrade-validation
Open

Fix server limit for product upgrades/downgrades#1356
KroZen-Dev wants to merge 2 commits into
Ctrlpanel-gg:developmentfrom
KroZen-Dev:fix/server-upgrade-validation

Conversation

@KroZen-Dev

@KroZen-Dev KroZen-Dev commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

Fixed server limit feature for product upgrades/downgrades. When a product has a serverlimit set (non-zero), users was able upgrade/downgrade to the product that already reached its limit for user.

Changes:

  • Added server limit validation when listing available upgrade products
  • Added server limit validation when upgrading a server to a different product
  • Added server limit validation in the validateUpgrade method

Type of Change

  • Bug fix

Testing

  • Tested creating a server when product limit is reached (should show error)
  • Tested upgrading to a product that has reached its limit (should show error)
  • Tested that products with serverlimit = 0 (unlimited) work as before
  • Tested that upgrading to the same product doesn't trigger limit check
  • Verified upgrade product list correctly marks limited products as "doesNotFit"

AI Assistance

  • I used AI tools to assist with this contribution

Checklist

  • My PR targets the development branch
  • Commit messages follow Conventional Commits
  • I have reviewed my own code
  • I have tested all affected functionality
  • No new warnings or errors introduced

@MrWeez MrWeez changed the title Add server limit for product changes Fix server limit for product upgrades/downgrades Jul 28, 2026

@MrWeez MrWeez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The limit-check logic is duplicated three times. Same block (count >= serverlimit && serverlimit != 0) is copy-pasted across getUpgradeOptions, upgrade(), and validateUpgrade(). On top of that, the check in upgrade() is effectively duplicated by the one inside validateUpgrade(), which upgrade() calls right afterward meaning the same COUNT query hits the DB twice within a single request. Worth extracting into a single private method, and reuse it everywhere (see example bellow), leaving upgrade() only responsible for returning its specific error message.

private function productLimitReached(User $user, Product $product): bool

@MrWeez MrWeez added the High Priority Critical. Act quickly for resolution label Jul 28, 2026
@KroZen-Dev
KroZen-Dev requested a review from MrWeez July 28, 2026 09:56

@MrWeez MrWeez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority Critical. Act quickly for resolution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants