Robustness: null-deref, div-by-zero and control-flow guards#1380
Conversation
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>
|
Warning Review limit reached
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
break;soBYNno longer fallsthrough and renders the
CHFsymbol.$discounted_priceto the baseprice so an unknown discount type fails safe instead of returning an undefined
value.
get_normalized_amount()guards against azero
durationbefore dividing.get_all_by_type('pending')validates theunserialized value is a
Sitebefore calling->set_type(), and filters outbad rows.
generate_magic_link()bails whenwu_get_site()returnsfalse(mirrors sibling methods) instead ofdereferencing null.
$customer(not$membership)before
$customer->get_id()when building migrated payment data.zones API result before iterating
->result.contentkey (falling back tovalue) so record content isn't dropped.