Skip to content

Commit

Permalink
Prevent Exception (joomla#40122)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
janschoenherr authored May 8, 2023
1 parent ebac512 commit 652222e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/content/fields/src/Extension/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 652222e

Please sign in to comment.