From 5e9e30f19ad922a9a980b4a78f3ab87818e9fa93 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Sun, 3 Dec 2017 21:30:35 +0100 Subject: [PATCH] [BUGFIX] fluid: Harden CountViewHelper The CountViewHelper calls count() on non-arrays or non-Countable objects. This throws warnings on PHP 7.2 - sanitize this call. Change-Id: Ie1932c31a099577cb0d344824a6441509aefbc03 Resolves: #83214 Releases: 7.6 Reviewed-on: https://review.typo3.org/54927 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- typo3/sysext/fluid/Classes/ViewHelpers/CountViewHelper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/CountViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/CountViewHelper.php index fc5b11760aac..99aa499118b7 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/CountViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/CountViewHelper.php @@ -78,6 +78,9 @@ class CountViewHelper extends AbstractViewHelper implements CompilableInterface if (is_object($subject) && !$subject instanceof \Countable) { throw new Exception('CountViewHelper only supports arrays and objects implementing \Countable interface. Given: "' . get_class($subject) . '"', 1279808078); } - return count($subject); + if (is_array($subject) || $subject instanceof \Countable) { + return count($subject); + } + return 0; } } -- GitLab