From 652222ea393aae2f58e3353cd7d985de831dfa2d Mon Sep 17 00:00:00 2001 From: janschoenherr Date: Mon, 8 May 2023 16:13:56 +0200 Subject: [PATCH] Prevent Exception (#40122) * Prevent Exception If $parts is `null` this will throw an exception. ```count(): Argument #1 ($value) must be of type Countable|array, null given``` This can happen if the context is e.g. the default context `text` from the `Joomla\CMS\HTML\Helpers\Content::prepare()` function. * Update fields.php --- plugins/content/fields/src/Extension/Fields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/content/fields/src/Extension/Fields.php b/plugins/content/fields/src/Extension/Fields.php index dfebe6c0185f1..517a880380baa 100644 --- a/plugins/content/fields/src/Extension/Fields.php +++ b/plugins/content/fields/src/Extension/Fields.php @@ -91,7 +91,7 @@ private function prepare($string, $context, $item) $parts = FieldsHelper::extract($context); - if (count($parts) < 2) { + if (!$parts || count($parts) < 2) { return $string; }