Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent TypeError due to null values in new elements #12077

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

AugustMiller
Copy link
Contributor

@AugustMiller AugustMiller commented Oct 8, 2022

Description

Adding a rule that extends BaseTextConditionRule to a field layout element causes the edit pages to throw a TypeError after creation, due to titles and field values being initialized as null.

This adds checks to the three problematic operators (BaseTextConditionRule::OPERATOR_BEGINS_WITH, BaseTextConditionRule::OPERATOR_ENDS_WITH, and BaseTextConditionRule::OPERATOR_CONTAINS) to ensure the values are strings, prior to calling the appropriate StringHelper methods.

Edit: Today I'm feeling less confident about the is_string() check… initially, I thought just an emptiness check would be fine, but null and '' are still different things, as far as the database is concerned. 😩 Empty strings do behave as expected.

@AugustMiller AugustMiller requested a review from a team as a code owner October 8, 2022 01:40
@brandonkelly brandonkelly self-requested a review as a code owner October 10, 2022 22:25
@brandonkelly brandonkelly merged commit 6bc4c9d into develop Oct 10, 2022
@brandonkelly
Copy link
Member

Looks good to me, thanks!

@brandonkelly brandonkelly deleted the am-null-basetextconditionrule branch October 10, 2022 22:25
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.

2 participants