Refactored array_filter() to explicitly check !is_null() AND strlen() in class-log.php#1473
Refactored array_filter() to explicitly check !is_null() AND strlen() in class-log.php#1473justinmaurerdotdev wants to merge 2 commits intoxwp:developfrom
Conversation
β¦ because passing 'strlen' as a callable caused warnings on null values.
|
Ouch, I wonder if |
|
Hmm, yeah. If it is being used to filter null values, then it likely will cause the same problem. The two refactoring options, as far as I can tell are:
I think Option 1 wins both for performance (Option 2 re-iterating the whole array) and presentation. There's no native In reality, it has to be something like So, we might as well combine them and save the extra loop. Though, this may be a sign of some upstream issue with how the how/why the null values are there in the first place... I'm new to this codebase, so I can't speak to that at all. |
|
I already created a PR for this in #1466 which also ensures that only strings are passed to |
β¦ because passing 'strlen' as a callable caused warnings on null values.
Fixes #1349.
The previously-merged commits did not, in fact, fix this issue. Null values were being passed through array_filter() with 'strlen' as the callable, but
strlen()no longer accepts null values. Should be fixed now, with an explicit null check added.OLD:
NEW:
Checklist
contributing.md).Release Changelog
Release Checklist
masterbranch.readme.txt.stream.php.Stable taginreadme.txt.classes/class-plugin.php.Change
[ ]to[x]to mark the items as done.