No Code Attached Yet
avatar hans2103
hans2103
19 Jul 2026

What happened?

PlgFieldsSubform::beforePrepareField() in plugins/fields/subform/src/Extension/Subform.php calls json_decode($field->value, true) guarded only by an is_array($field->value) check. Any custom field of type Subform that has never been given a value has $field->value === null. Passing null to json_decode() triggers a PHP 8.1+ deprecation notice.

  1. Create a custom field of type Subform on any content type (e.g. Articles).
  2. View/render an item that has never had a value saved for that field (value is null).
  3. With deprecation notices displayed/logged (PHP 8.1+), the following appears:
Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in plugins/fields/subform/src/Extension/Subform.php on line 143

I noticed this on a live Joomla 6.1.2 site, and confirmed the same unguarded call exists on the current joomla-cms 6.1-dev/main branches.

A related but distinct issue, #39768, previously reported a fatal error here for array values (fixed by #39842, which added the is_array() check) — but that fix never covered the null case.

I've opened a fix for this: #48122 (adds an early return for null/empty values, same pattern as the existing is_array() guard).

Version

6.1

Expected result

No deprecation notice is raised when a Subform field has no saved value.

Actual result

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated notice is raised/logged.

System Information

Joomla! 6.1.2 Stable, PHP 8.1+ (deprecation notices visible/logged).

Additional Comments

This issue and its accompanying pull request (#48122) were drafted with AI assistance (Claude Code) and reviewed by me on a live site before submission, per the Generative AI policy.

avatar hans2103 hans2103 - open - 19 Jul 2026
avatar joomla-cms-bot joomla-cms-bot - change - 19 Jul 2026
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Jul 2026

Add a Comment

Login with GitHub to post a comment