Skip to content

fix(settings): preserve legacy false toggle values - #1674

Merged
superdav42 merged 2 commits into
mainfrom
feature/auto-20260726-121305
Jul 26, 2026
Merged

fix(settings): preserve legacy false toggle values#1674
superdav42 merged 2 commits into
mainfrom
feature/auto-20260726-121305

Conversation

@superdav42

@superdav42 superdav42 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve legacy saved \"false\" strings for toggle/numeric settings instead of treating them as missing.
  • Keep the settings recovery for text fields that were previously corrupted to display false.
  • Add regression coverage for the free-trial payment-method setting and settings fallback behavior.

Root cause

A previous settings recovery change treated every saved literal \"false\" value as missing. For installs where allow_trial_without_payment_method had been saved as the string \"false\", that changed checkout behavior after update: the value fell back to the default off state, so Stripe started asking for card details during free trials.

Verification

  • vendor/bin/phpcs inc/class-settings.php tests/WP_Ultimo/Settings_Test.php tests/unit/Cart_Should_Collect_Payment_Test.php
  • vendor/bin/phpunit --filter Settings_Test
  • vendor/bin/phpunit --filter Cart_Should_Collect_Payment_Test
  • vendor/bin/phpstan analyse inc/class-settings.php --memory-limit=512M

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of saved settings containing the literal "false".
    • Text-like settings now correctly treat the stored "false" as missing and fall back to defaults.
    • Toggle and numeric-like settings preserve legacy "false" behavior.
    • Trial carts configured to skip payment details continue to avoid requesting payment information.
  • Tests
    • Added coverage for "false" handling across text, toggle, and numeric-like settings.
    • Added a regression test ensuring legacy trial-cart payment behavior remains unchanged.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f11f0c6-80a5-460e-bf1b-69c1d183097e

📥 Commits

Reviewing files that changed from the base of the PR and between ba426d6 and ca23c55.

📒 Files selected for processing (2)
  • inc/class-settings.php
  • tests/WP_Ultimo/Settings_Test.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/WP_Ultimo/Settings_Test.php
  • inc/class-settings.php

📝 Walkthrough

Walkthrough

Settings::get_setting() now interprets stored "false" values according to the effective default type. Text settings fall back to defaults, while toggle and numeric-string settings preserve the literal value. Tests cover setting resolution and trial cart payment handling.

Changes

Default-aware false setting handling

Layer / File(s) Summary
Default-aware setting resolution
inc/class-settings.php
Settings::get_setting() uses private helpers to classify explicit or registered defaults and decide whether the stored string "false" is missing.
Setting and cart regression coverage
tests/WP_Ultimo/Settings_Test.php, tests/unit/Cart_Should_Collect_Payment_Test.php
Tests reset affected settings and verify text settings fall back to defaults, toggle and numeric-string settings preserve "false", and trial carts do not collect payment.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: preserving legacy literal "false" setting values instead of treating them as missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 feature/auto-20260726-121305

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.

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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/class-settings.php`:
- Around line 285-292: Update the setting type validation around
get_setting_defaults() so numeric-string defaults such as precision and
next_invoice_number are classified as numeric rather than generic strings,
allowing saved 'false' values to retain the intended numeric-setting
compatibility behavior. Add a regression assertion covering at least one of
these settings.
🪄 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 Plus

Run ID: f4d7a60b-5357-4b4d-9be9-378545b01d27

📥 Commits

Reviewing files that changed from the base of the PR and between 5ab40c6 and ba426d6.

📒 Files selected for processing (3)
  • inc/class-settings.php
  • tests/WP_Ultimo/Settings_Test.php
  • tests/unit/Cart_Should_Collect_Payment_Test.php

Comment thread inc/class-settings.php Outdated
@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42
superdav42 merged commit 1238102 into main Jul 26, 2026
11 checks passed
@superdav42

Copy link
Copy Markdown
Collaborator Author

Summary

  • Preserve legacy saved \"false\" strings for toggle/numeric settings instead of treating them as missing.
  • Keep the settings recovery for text fields that were previously corrupted to display false.
  • Add regression coverage for the free-trial payment-method setting and settings fallback behavior.

Root cause

A previous settings recovery change treated every saved literal \"false\" value as missing. For installs where allow_trial_without_payment_method had been saved as the string \"false\", that changed checkout behavior after update: the value fell back to the default off state, so Stripe started asking for card details during free trials.

Verification

  • vendor/bin/phpcs inc/class-settings.php tests/WP_Ultimo/Settings_Test.php tests/unit/Cart_Should_Collect_Payment_Test.php
  • vendor/bin/phpunit --filter Settings_Test
  • vendor/bin/phpunit --filter Cart_Should_Collect_Payment_Test
  • vendor/bin/phpstan analyse inc/class-settings.php --memory-limit=512M


Merged via PR #1674 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).


aidevops.sh v3.32.181 spent 58s on this as a headless bash routine.

@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant