Skip to content

Commit 75d1f49

Browse files
committed
Fixed #18656
1 parent b488a5d commit 75d1f49

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Fixed a bug where recent changes could be lost when creating an element or applying a draft, if there were validation errors. ([#18657](https://github.com/craftcms/cms/issues/18657))
1616
- Fixed a bug where nested elements would get soft-deleted after running the `entrify/global-set` command. ([#18650](https://github.com/craftcms/cms/issues/18650))
1717
- Fixed a bug where the “Max Authors” section setting was visible for Single sections.
18+
- Fixed an exception that would be thrown when attempting to access undefined keys within `craft\fields\data\JsonData` objects from Twig. ([#18656](https://github.com/craftcms/cms/issues/18656))
1819

1920
## 5.9.18 - 2026-03-26
2021

src/fields/data/JsonData.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Traversable;
1717
use yii\base\BaseObject;
1818
use yii\base\InvalidCallException;
19+
use yii\base\UnknownMethodException;
1920

2021
/**
2122
* JSON field data class.
@@ -38,6 +39,20 @@ public function __toString(): string
3839
return $this->getJson();
3940
}
4041

42+
public function __call($name, $params)
43+
{
44+
try {
45+
return parent::__call($name, $params);
46+
} catch (UnknownMethodException $e) {
47+
if (!empty($params)) {
48+
throw $e;
49+
}
50+
51+
// This is probably just Twig falling back to calling a properly like it's a method
52+
return null;
53+
}
54+
}
55+
4156
public function getType(): string
4257
{
4358
$type = gettype($this->value);

0 commit comments

Comments
 (0)