Bug #106638
openDouble json_encode when persisting an Extbase model property with database field type "JSON"
0%
Description
When persisting an Extbase model with a property mapped to a database field of type JSON, the value gets double-encoded with json_encode.
Background: In typo3/cms-extbase/Classes/Persistence/Generic/Backend.php → persistObject(), all property values must either be strings or be converted to strings. This means an array or object must already be passed as a JSON string.
Additionally, in vendor/typo3/cms-core/Classes/Database/Connection.php → ensureDatabaseValueTypes(), the database field type is checked. If the type is json, the string is passed through json_encode again — specifically in vendor/doctrine/dbal/src/Types/JsonType.php → convertToDatabaseValue().
As a result, the field (TCA type json) is no longer recognized as valid JSON in the backend.
Workaround: Change the field type in the database from json to longtext.
Question: Is there a recommended solution or approach to preserve the use of the json field type?
Updated by Stefan Bürk 19 days ago
- Status changed from New to Accepted
- Assignee set to Stefan Bürk
Extbase never had "json" support, and misses TCA type=json (DB type json) support.
At least the double encoding should be prevented in the first step and as "bugfix",
literally ignoring TCA/DB Type json for now.
In v14 support for extbase (DECODE + ENCODE) can be added in a dedicated step,
which is not really suitable as bugfix due to changes required for models I guess.
Updated by Gerrit Code Review 15 days ago
- Status changed from Accepted to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89293
Updated by Gerrit Code Review 15 days ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89293
Updated by Stefan Bürk 15 days ago
- Related to Feature #99062: Native JSON field support in Doctrine DBAL added
Updated by Gerrit Code Review 15 days ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89293
Updated by Gerrit Code Review 15 days ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89293