- Issue created by @mweirath
- π§πͺBelgium BramDriesen Belgium π§πͺ
@deepali sardana Your MR introduces code sniff issues. It's not recommended to just blindly copy over what might fix a given issue from the issue summary. Also I don't see any need to wrap it in round brackets. I think the only thing relevant here is the string conversion, which might actually crash if the value is NULL. This might need a fix higher up.
But given your track record, you probably will not look again at this issue and just continue on the next one.
Fixing some meta data as I go.
- π¨π¦Canada teknocat
@bramdriesen I just ran into this and reviewed the fix provided by @deepali.
Firstly, I the only code sniff issue is with the lack of a space between
(string)
and$value
, but that's just a coding standards issue and quick to fix. There's also a sniff error on theelseif
, which is meant to be on the next line per Drupal coding standards, but that wasn't a result of the patch.Wrapping the turnery in parentheses is required to fix the issue, though I'm not exactly sure why that makes a difference. If there's a concern about $value being null when trying to type it as a string, then the second part of the ternary could have a second turnery instead, to be safe, as such:
$user_input .= ' ' . (is_array($value) ? implode(' ', $value) : ($value ?: ''));
So either that, or @deepali's, change works fine to resolve the error.
- π¨π¦Canada teknocat
By the way, casting $value as a string will just result in an empty string if it's null, so that's not an issue.
- Merge request !30Wrap ternary expression in parenthesis to avoid PHP TypeError if $value is string β (Open) created by teknocat
- π¨π¦Canada teknocat
Ok, so the patch derived from either of the merge requests here won't apply to the current release because it includes changes from other patches that haven't all been merged and added to a release yet.
So using the 2.0.x-dev branch with the patch from either of these merge requests should do the trick for now and cover you on the other issues that haven't been included in a new release version yet (I think).
Looking forward to a new release soon so we can do away with the patches.
- Status changed to Needs work
9 days ago 2:16pm 1 April 2025 - πΊπΈUnited States sclsweb
I'm posting a patch for 2.0.10 for anyone else who may need it. I didn't want to switch to the dev branch right now.
- ππΊHungary nagy.balint
I had the same issue, patch #10 fixed it for me on 2.0.10