You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle array input in phone validation and request sanitizing - #3618
Lite half of Strategy11/formidable-pro#6915. The Pro half is Strategy11/formidable-pro#6916.
Broken: posting an array (field[]=x) to a phone/formatted text field, or to a key FrmEntry::sanitize_entry_post sanitizes (form_key, item_key, frm_action), threw a fatal TypeError on PHP 8.
Changed:
FrmEntryValidate::validate_phone_field: an array value adds the field's "invalid" error.
FrmAppHelper::sanitize_request: an array value becomes ''. The only caller maps every key to a scalar sanitizer.
Verified: CI run on the test-only commit failed exactly the 2 new tests with preg_match(): Argument #2 ($subject) must be of type string, array given (951 tests, 2 errors). The run on the fix commit is linked in the checks below.
Not done: the Array to string conversion warnings from the issue were not traced.
We reviewed changes in a0b9742...65775a3 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
The reason will be displayed to describe this comment to others. Learn more.
Approve. No blocking findings.
Repro, before/after (PHP 8.2 CLI, real validate_phone_field and sanitize_request from each tree, WP helpers stubbed): on master, an array phone value throws TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given, and an array frm_action throws a TypeError from the sanitizer. On this branch the phone array returns the field's "invalid" error and frm_action becomes ''. Valid and invalid string phones behave the same on both, and an unmapped array key is left alone.
Fix location: the single caller of sanitize_request (FrmEntry::sanitize_entry_post) maps only scalar sanitizers, so blanking an array there is correct. An empty array also reaches validate_phone_field ([] != '' is true in the caller's guard) and is caught by the same is_array() check.
Tests: both new tests exercise the changed branches. The PR description records them failing on the test-only commit.
Red checks, not caused by this PR: Psalm's annotations are all MissingPureAnnotation in FrmAbilities*Controller.php (files this PR doesn't touch). The two DeepSource comments ("undefined method assertArrayHasKey/assertSame") are false positives, because FrmUnitTest extends the WP PHPUnit case.
Not exercised: a live WordPress request with field[]=x (the Playground preview env would not boot here); the Array to string conversion warnings and the Pro half (formidable-pro#6916) are outside this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lite half of Strategy11/formidable-pro#6915. The Pro half is Strategy11/formidable-pro#6916.
Broken: posting an array (
field[]=x) to a phone/formatted text field, or to a keyFrmEntry::sanitize_entry_postsanitizes (form_key,item_key,frm_action), threw a fatalTypeErroron PHP 8.Changed:
FrmEntryValidate::validate_phone_field: an array value adds the field's "invalid" error.FrmAppHelper::sanitize_request: an array value becomes''. The only caller maps every key to a scalar sanitizer.Verified: CI run on the test-only commit failed exactly the 2 new tests with
preg_match(): Argument #2 ($subject) must be of type string, array given(951 tests, 2 errors). The run on the fix commit is linked in the checks below.Not done: the
Array to string conversionwarnings from the issue were not traced.Part of Strategy11/formidable-pro#6915
🤖 Generated with Claude Code