Robustness: null-deref, div-by-zero and control-flow guards#1380
Robustness: null-deref, div-by-zero and control-flow guards#1380vuckro wants to merge 5 commits into
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughEight isolated defensive fixes: a missing ChangesDefensive Safety Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Stuck-merge detector: PR has been merge-eligible but unmerged past the thresholdThe pulse merge pass has classified PR #1380 as Failing checks on PR #1380
Worker guidance for the next attempt
Why you're seeing thisEvery pulse cycle (~120s) the deterministic merge pass re-evaluates open PRs. PRs that pass APPROVED + MERGEABLE but fail required checks have historically been re-evaluated silently every cycle until a human noticed. The stuck-merge detector (t3193) surfaces them after Posted automatically by aidevops.sh v3.20.57 automated scan. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@inc/sso/class-magic-link.php`:
- Around line 128-130: The site existence check for `wu_get_site($site_id)`
occurs after the token has already been persisted via `set_transient()` in the
Magic Link class. If the site lookup fails, this leaves an orphaned transient
until TTL expiry. Move the `wu_get_site($site_id)` call and the null guard check
before the `set_transient()` calls to ensure the site exists before any token is
stored. This prevents unnecessary transient writes when the site validation
fails.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: a90e24e5-0493-4856-90b4-064a5c0da1ae
📒 Files selected for processing (8)
inc/functions/currency.phpinc/functions/discount-code.phpinc/installers/class-migrator.phpinc/integrations/host-providers/class-cloudflare-host-provider.phpinc/integrations/host-providers/class-dns-record.phpinc/models/class-membership.phpinc/models/class-site.phpinc/sso/class-magic-link.php
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.Summary by CodeRabbit