-
Notifications
You must be signed in to change notification settings - Fork 823
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
FIX Use empty array as a fallback for preg_split within DBText summary #9696
FIX Use empty array as a fallback for preg_split within DBText summary #9696
Conversation
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.
All of these are parts that are immediately expecting iterable results, so LGTM. Thanks!
The only thing I'd suggest would be a test that fails without this patch, to ensure we don't regress. |
Is there anywhere a test already dealing with invalid UTF string that I could look at? |
|
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 agree a test would be good, but we shouldn't prevent a merge that is clearly a good enhancement just because existing testing doesn't cover a fairly obvious failure case.
404f300
to
531140c
Compare
Rebased on 4.8 and added a test for DBText->Summary, but Travis fails on version resolution ¯\(ツ)/¯ before it can run it. |
If the content is invalid for whatever reason e.g. when instantiating a DBText field to get a summary of text through `DBField::create_field('Text', $content)->Summary(10)`, preg_split returns false and the rest of the code expects an array. This tweak ensures an array is always returned even when preg_split fails.
b096452
to
9cc23c9
Compare
Thanks @michalkleiner - but since of the new tests are failing, are you happy to keep looking into it? |
Yep @dhensby, will get it through ;-) The tests were not even running since I targetted 4.8, now they are after a rebase so can finally finish resolving this. |
9cc23c9
to
0bd5b98
Compare
@dhensby all green now ;-) |
If the content is invalid for whatever reason e.g. when instantiating a DBText field to get a summary of text through
DBField::create_field('Text', $content)->Summary(10)
from a UTF-malformed string, preg_split returns false and the rest of the code expects an array.This fix ensures an array is always returned even when preg_split fails.