Length filter non-mb_string on 7.x fix.

This commit is contained in:
SpacePossum
2017-05-12 10:40:10 +02:00
parent d884330572
commit 3aa2e884ae
+9 -1
View File
@@ -1363,6 +1363,10 @@ else {
*/
function twig_length_filter(Twig_Environment $env, $thing)
{
if (null === $thing) {
return 0;
}
if (is_scalar($thing)) {
return strlen($thing);
}
@@ -1371,7 +1375,11 @@ else {
return strlen((string) $thing);
}
return count($thing);
if ($thing instanceof \Countable || is_array($thing)) {
return count($thing);
}
return 1;
}
/**