Skip to content

Fix renew error for admins#499

Merged
sorinmarta merged 1 commit into
masterfrom
fix-348
Apr 14, 2026
Merged

Fix renew error for admins#499
sorinmarta merged 1 commit into
masterfrom
fix-348

Conversation

@sorinmarta
Copy link
Copy Markdown
Contributor

fixes https://github.com/Strategy11/business-directory-premium/issues/348

Fix fatal error when admin renews an expired recurring listing. The fee_payment() return value was silently discarded, causing execution to fall through to get_checkout_url() on a null payment object.

@sorinmarta sorinmarta added the run analysis Runs phpcs and phpunit label Apr 14, 2026
@sorinmarta sorinmarta requested a review from Copilot April 14, 2026 09:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a fatal error when an admin renews an expired recurring listing by preventing execution from falling through to $payment->get_checkout_url() when no valid payment object exists.

Changes:

  • Capture and return the result of fee_payment() during the “go to checkout” action, falling back to plan selection if no redirect occurs.
  • Guard the final checkout redirect to avoid calling get_checkout_url() on a null $payment, falling back to plan selection instead.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sorinmarta sorinmarta merged commit ce60d9d into master Apr 14, 2026
11 of 12 checks passed
@sorinmarta sorinmarta deleted the fix-348 branch April 14, 2026 09:29
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Updated the checkout redirection flow in the renew listing controller's dispatch method to handle missing payment objects. Instead of unconditionally calling fee_payment() and dereferencing its result, the result is now stored and checked; if invalid, the controller renders plan selection as a fallback.

Changes

Cohort / File(s) Summary
Checkout Control Flow Enhancement
includes/controllers/pages/class-renew-listing.php
Modified the dispatch() method to conditionally handle the checkout redirection path. The fee_payment() result is now captured and validated before proceeding. Added fallback rendering of plan selection when payment object is unavailable, and made the final checkout redirect conditional on payment object existence.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a fatal error when admins renew expired recurring listings.
Description check ✅ Passed The description is directly related to the changeset, explaining the bug fix (discarded fee_payment return value) and the fatal error it caused.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-348

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.46)

PHPStan was skipped because the user-provided config is missing the required paths: directive.


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

run analysis Runs phpcs and phpunit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants