Skip to content

Robustness: null-deref, div-by-zero and control-flow guards#1380

Open
vuckro wants to merge 1 commit into
Ultimate-Multisite:mainfrom
vuckro:fix/robustness-hardening-bundle
Open

Robustness: null-deref, div-by-zero and control-flow guards#1380
vuckro wants to merge 1 commit into
Ultimate-Multisite:mainfrom
vuckro:fix/robustness-hardening-bundle

Conversation

@vuckro

@vuckro vuckro commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

A bundle of small, isolated robustness fixes found during a reliability review.
Each change is independent and a few lines; grouped for easier review.

  • functions/currency.php — add missing break; so BYN no longer falls
    through and renders the CHF symbol.
  • functions/discount-code.php — initialise $discounted_price to the base
    price so an unknown discount type fails safe instead of returning an undefined
    value.
  • models/class-membership.phpget_normalized_amount() guards against a
    zero duration before dividing.
  • models/class-site.phpget_all_by_type('pending') validates the
    unserialized value is a Site before calling ->set_type(), and filters out
    bad rows.
  • sso/class-magic-link.phpgenerate_magic_link() bails when
    wu_get_site() returns false (mirrors sibling methods) instead of
    dereferencing null.
  • installers/class-migrator.php — guard $customer (not $membership)
    before $customer->get_id() when building migrated payment data.
  • integrations/host-providers/class-cloudflare-host-provider.php — guard the
    zones API result before iterating ->result.
  • integrations/host-providers/class-dns-record.php — read the Hestia record
    content key (falling back to value) so record content isn't dropped.

A bundle of small, isolated robustness fixes found during a reliability review:

- functions/currency.php: add missing `break;` so BYN no longer falls through
  to the CHF symbol.
- functions/discount-code.php: initialise $discounted_price to the base price so
  an unknown discount type fails safe instead of returning an undefined value.
- models/class-membership.php: get_normalized_amount() guards against a zero
  duration before dividing.
- models/class-site.php: get_all_by_type('pending') validates the unserialized
  value is a Site before calling ->set_type(), and filters out bad rows.
- sso/class-magic-link.php: generate_magic_link() bails when wu_get_site()
  returns false instead of dereferencing null (mirrors sibling methods).
- installers/class-migrator.php: guard $customer (not $membership) before
  calling $customer->get_id() when building migrated payment data.
- integrations/host-providers/class-cloudflare-host-provider.php: guard the
  zones API result before iterating ->result.
- integrations/host-providers/class-dns-record.php: read the Hestia record
  'content' key (falling back to 'value') so record content is not dropped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@vuckro, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 12 minutes and 7 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f29d64f-8102-4544-a2c1-cc98264a29de

📥 Commits

Reviewing files that changed from the base of the PR and between 1310078 and ad94b1b.

📒 Files selected for processing (8)
  • inc/functions/currency.php
  • inc/functions/discount-code.php
  • inc/installers/class-migrator.php
  • inc/integrations/host-providers/class-cloudflare-host-provider.php
  • inc/integrations/host-providers/class-dns-record.php
  • inc/models/class-membership.php
  • inc/models/class-site.php
  • inc/sso/class-magic-link.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

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