-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
[REF] Fix handling of NULL values in count_characters smarty modifier… #23318
[REF] Fix handling of NULL values in count_characters smarty modifier… #23318
Conversation
… by creating a CiviCRM specific one that handles them
(Standard links)
|
@seamuslee001 I added a commit to fixup the code-style issue. I couldn't figure out how to reproduce a warning from the snippet in Did you originally observe the error in GenCode -- or was that just an incidental bit that up during search/replace? (I think it's fine to change that one proactively -- just not clear but what to test.) |
I see the schema one is doing something - before the patch if I do
Then I get a bunch of errors about line 27: Am also using php 8.1.2. If I only apply the schema part of the patch I don't get those, so it must be from there. |
|
||
if (is_null($string)) { | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is mergeable as-is just noting some possible improvements:
- The check for null here could come before potentially passing to strlen()
- While copied from the original function, strlen isn't multibyte-friendly. In the places where it's used currently it doesn't make too much difference.
- The use in schema.xml is really checking for something like
if $field.default !== null && $field.default !== ''
(i.e. '0' is allowed but not null or blank). So could avoid the function.
Going to merge but I'm going to put up a followup to move the check for null to ahead of sending it to strlen. |
… by creating a CiviCRM specific one that handles them
Overview
This fixes a PHP8.1 issue whetre passing NULL to the 2nd parameter to preg_match_all is deprecated
Before
Deprecation error on php8.1
After
no deprecation error
ping @eileenmcnaughton @demeritcowboy