Fix - Prevent TypeError in CheckboxesField::regex() when stored value is invalid JSON#3647
Open
RomainLvr wants to merge 1 commit into
Open
Fix - Prevent TypeError in CheckboxesField::regex() when stored value is invalid JSON#3647RomainLvr wants to merge 1 commit into
RomainLvr wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes description
Checklist
Please check if your PR fulfills the following specifications:
Description
When rendering the
plugin_formcreator_solved_issuesdashboard widget, aTypeErroris thrown:preg_grep(): Argument #2 ($array) must be of type array, null givenThis happens when a form answer contains a checkbox field with a regex visibility condition, and the stored JSON value is corrupted or invalid.
json_decode()returnsnullon invalid input, leaving$this->value = null, which then causespreg_grep()to throw.A secondary bug was also found in
LdapselectField::regex(), which incorrectly usedpreg_grep()on a plain string value instead ofpreg_match().Changes
CheckboxesField::deserializeValue(): addis_array()guard afterjson_decode()so$this->valuealways ends up as an array, even when the stored data is malformed. This mirrors the existing pattern inActorField.LdapselectField::regex(): replacepreg_grep()withpreg_match(), consistent withRadiosFieldwhich holds a single string value.tests/CheckboxesField.php: addtestRegex()covering valid match, no match, invalid JSON, and JSON-null cases.