Fix: should_user_verify_order_email() case-sensitive email comparison#62974
Conversation
Resolve BlocksUtil conflict: keep upstream null-check (null === template->content).
…sensitive comparison and non-empty checks for session and supplied emails.
Testing GuidelinesHi @woocommerce/rubik, Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
📝 WalkthroughWalkthroughUpdates WooCommerce utilities: makes email comparisons case-insensitive with empty-value guards in the Users utility, changes a template content null-check to an empty check in BlocksUtil, and adds a patch changelog entry describing the fix for guest order payment access when email case differs. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@plugins/woocommerce/src/Internal/Utilities/BlocksUtil.php`:
- Around line 68-78: Remove the Git merge conflict markers and keep the branch
that uses the empty() check for the template content: replace the conflicting
block (the lines with <<<<<<<, =======, >>>>>>>) in the conditional that checks
$template->content with a single if that uses empty( $template->content ) and
returns array() when true; ensure the resulting code in BlocksUtil (the
conditional around $template->content) has no leftover conflict markers and
preserves the return array() behavior.
|
✅ Actions performedReview triggered.
|
mikejolley
left a comment
There was a problem hiding this comment.
Thanks for providing the fix. I'm happy with this solution so this can be merged once the CI is passing 👍🏻
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR fixes a bug where email verification for guest checkout orders was case-sensitive, causing verification failures when customers entered their email address in a different case than what was stored in the order.
Problem:
When a guest customer attempts to verify their email address to access the order payment or order received page, the comparison between the submitted email and the order's billing email was performed using strict equality (
===), which is case-sensitive. This meant that if an order had a billing email of'[email protected]'and the customer entered'[email protected]', the verification would fail even though these represent the same email address.Solution:
Changed the email comparison in
Users::should_user_verify_order_email()to usestrcasecmp()for case-insensitive comparison, consistent with the approach already used inOrderAuthorizationTrait::validate_billing_email_matches_order(). This ensures that email addresses are compared in a case-insensitive manner, which aligns with standard email behavior where the local part (before @) is typically treated as case-insensitive by most email providers.Changes:
$session_email_matchcomparison to usestrcasecmp()instead of strict equality$supplied_email_matchcomparison to usestrcasecmp()instead of strict equalityFiles changed:
plugins/woocommerce/src/Internal/Utilities/Users.php(lines 132-133)Closes #62917
(For Bug Fixes) Bug introduced in PR # .
Screenshots or screen recordings:
N/A - This is a backend fix with no UI changes.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Create a test order in WooCommerce admin:
[email protected])/checkout.html/order-pay/{order_id}?pay_for_order=true&key={order_key})Wait for the grace period to expire:
woocommerce_order_email_verification_grace_periodto set it to 0 for testingTest case-insensitive email verification:
[email protected], enter[email protected]or[email protected])Test various case combinations:
[email protected][email protected][email protected][email protected]Test edge cases:
[email protected])Testing that has already taken place:
Environment:
Testing performed:
OrderAuthorizationTrait::validate_billing_email_matches_order())Analysis:
strcasecmp()which is the standard PHP function for case-insensitive string comparisonMilestone
Changelog entry
Changelog Entry Details
Significance
Type
Message
Fixed case-sensitive email verification issue that prevented guests from accessing order payment pages when entering their email address in a different case than stored in the order.
Changelog Entry Comment
Comment