Fix WC Memberships: null guard and retry queue cleanup #838#896
Fix WC Memberships: null guard and retry queue cleanup #838#896
Conversation
sync_membership() guards against null membership lookups. process_single_sync() clears stale queue at retry cap instead of silently abandoning stranded users. Co-Authored-By: Claude via AIContext
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds defensive handling in the WooCommerce membership synchronizer: ChangesMembership Sync Error Handling & Reconciliation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.51)PHPStan was skipped because the sandbox runner could not parse its output. Review rate limit: 2/5 reviews remaining, refill in 27 minutes and 18 seconds. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@php/classes/integrations/woocommerce/class-wc-memberships-integrator.php`:
- Around line 287-290: When the retry cap is reached in
class-wc-memberships-integrator (the block using self::SINGLE_SYNC_DATA_OPTION),
do not unconditionally call delete_option which can remove concurrent entries
added by prepare_single_sync(); instead load the current option with
get_option(self::SINGLE_SYNC_DATA_OPTION, []), compute the difference between
the current stored users and the stranded $snapshot['users'] (remove only the
users that belong to the capped snapshot), update the option with the remaining
users (and preserve other metadata), and only delete the option if no users
remain; keep the logger->log call but remove the unconditional delete_option
call and replace it with update_option when needed.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b18532c5-af76-4846-801b-b0aebfb38883
📒 Files selected for processing (1)
php/classes/integrations/woocommerce/class-wc-memberships-integrator.php
Reuse reconcile_sync_data() to drop only capped snapshot users instead of unconditionally deleting the queue option. Co-Authored-By: Claude via AIContext
Summary
sync_membership()against null membership lookups to prevent fatal errors whenget_user_membership()returns nullSINGLE_SYNC_DATA_OPTIONqueue when the 10-attempt retry cap is reached, so stranded users don't block future syncsTest plan
WCMembershipsIntegratorTestsuiteSummary by CodeRabbit