Skip to content

t741: fix(checkout): add form_has_auto_generate_password() and strip JS password rules#742

Merged
superdav42 merged 1 commit intomainfrom
feature/741-form-has-auto-generate-password
Apr 3, 2026
Merged

t741: fix(checkout): add form_has_auto_generate_password() and strip JS password rules#742
superdav42 merged 1 commit intomainfrom
feature/741-form-has-auto-generate-password

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented Apr 3, 2026

Summary

  • Adds form_has_auto_generate_password(): bool protected method to the Checkout class that iterates form settings to detect password fields with auto_generate_password enabled
  • Uses this method in get_js_validation_rules() to unset() the password, password_conf, and valid_password rules when auto-generate is active
  • Prevents the JS validator from blocking form submission on a password field that is never rendered

Problem

After PR #737 (simple checkout form template) merged, checkout forms using auto-generated passwords had their JS validator require a password field that was never shown, blocking form submission.

Acceptance Criteria

  • form_has_auto_generate_password() method exists in Checkout class
  • get_js_validation_rules() strips password rules when auto-generate is enabled
  • PHPStan level 0 passes

Closes #741


aidevops.sh v3.5.718 plugin for OpenCode v1.3.0 with claude-sonnet-4-6 spent 2m and 5,470 tokens on this as a headless worker.

Summary by CodeRabbit

  • Refactor
    • Improved internal checkout form logic for auto-generated password field handling and validation rules processing.

…sword rules

Add protected form_has_auto_generate_password() method to the Checkout
class that iterates form settings to detect password fields with
auto_generate_password enabled.

Use this method in get_js_validation_rules() to unset the password,
password_conf, and valid_password rules when auto-generate is active,
preventing the JS validator from blocking submission on a field that
is never rendered.

Closes #741
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bcc7e42c-0bc0-4d0c-acaa-e366d0d48fa7

📥 Commits

Reviewing files that changed from the base of the PR and between 6ded15a and 0b3f3fa.

📒 Files selected for processing (1)
  • inc/checkout/class-checkout.php

📝 Walkthrough

Walkthrough

This change refactors password validation detection in the checkout class by extracting inline logic into a dedicated protected helper method. The helper form_has_auto_generate_password() inspects checkout form settings for auto-generated password fields, and get_js_validation_rules() now calls this method to conditionally remove password-related JavaScript validation rules.

Changes

Cohort / File(s) Summary
Checkout Form Password Validation
inc/checkout/class-checkout.php
Added protected method form_has_auto_generate_password() to detect auto-generated password fields in checkout forms. Refactored get_js_validation_rules() to use this helper instead of inline detection logic, and changed rule removal from empty string assignment to unset() calls for password, password_conf, and valid_password keys.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A helper born from tangled lines,
Now password checks align so fine.
No more inline detection's fuss,
Just a method handling us!
Validation flows with grace anew,
Refactored clean and pure and true! ✨

🚥 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 PR title clearly describes the main changes: adding form_has_auto_generate_password() method and stripping JS password rules for auto-generate scenarios.
Linked Issues check ✅ Passed All coding requirements from issue #741 are met: form_has_auto_generate_password() protected method added, get_js_validation_rules() updated to unset password rules when auto-generate is enabled.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of fixing JS validation for auto-generate-password forms; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 feature/741-form-has-auto-generate-password

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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

🔨 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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Performance Test Results

Performance test results for 1b68f44 are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 40 37.78 MB 828.50 ms (-20.00 ms / -2% ) 168.00 ms (+6.50 ms / +4% ) 1062.00 ms (+45.00 ms / +4% ) 2024.00 ms 1943.80 ms 86.95 ms (-2.50 ms / -3% )
1 56 49.02 MB 925.50 ms 145.00 ms 1070.50 ms 2016.00 ms (-44.00 ms / -2% ) 1931.40 ms (-48.05 ms / -2% ) 80.10 ms (+1.75 ms / +2% )

@superdav42 superdav42 merged commit bbad652 into main Apr 3, 2026
11 checks passed
@superdav42 superdav42 deleted the feature/741-form-has-auto-generate-password branch April 3, 2026 00:33
superdav42 added a commit that referenced this pull request Apr 3, 2026
…password

- Signup_Field_Password_Test: 6 new tests covering auto_generate_password
  defaults, get_fields toggle, to_fields_array hidden flag emission,
  v-show guards on strength meter and confirm field
- Checkout_Form_Test: 11 new tests covering simple template validation,
  use_template() structure, field presence, auto-generate flags on
  username/password/site_title/site_url, filterable hook, and save path

All 17 tests pass against the implementation already in main (PRs #737, #739, #742).

Closes #746
superdav42 added a commit that referenced this pull request Apr 3, 2026
…erated credentials (#747)

* chore: add t524 simple checkout form feature to backlog (re-implement PR #740)

* test(checkout): add unit tests for simple template and auto-generate password

- Signup_Field_Password_Test: 6 new tests covering auto_generate_password
  defaults, get_fields toggle, to_fields_array hidden flag emission,
  v-show guards on strength meter and confirm field
- Checkout_Form_Test: 11 new tests covering simple template validation,
  use_template() structure, field presence, auto-generate flags on
  username/password/site_title/site_url, filterable hook, and save path

All 17 tests pass against the implementation already in main (PRs #737, #739, #742).

Closes #746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(checkout): commit JS validation fix for auto-generate-password forms

1 participant