Avoid array_filter on explode()

The array_filter is likely meant to empty the array if the empty string
was exploded ( `explode( "\n", '' ) === [ '' ]` ). However, it can also
remove other stuff, e.g. the string '0'. An explicit comparison is
easier to read & interpret, marginally faster, and avoids rare but not
impossible edge cases.

Change-Id: Ie77d65b56319664a2ac370f32341dc72b619a635
This commit is contained in:
Daimona Eaytoy 2020-10-08 18:54:36 +02:00
parent b7cda4de4c
commit 7a1d6dbdbb

View file

@ -412,7 +412,7 @@ class AbuseFilterHooks {
$tags = [];
foreach ( $res as $row ) {
$tags = array_merge(
array_filter( explode( "\n", $row->afa_parameters ) ),
$row->afa_parameters ? explode( "\n", $row->afa_parameters ) : [],
$tags
);
}
@ -430,7 +430,7 @@ class AbuseFilterHooks {
foreach ( $res as $row ) {
$tags = array_merge(
array_filter( explode( "\n", $row->afa_parameters ) ),
$row->afa_parameters ? explode( "\n", $row->afa_parameters ) : [],
$tags
);
}