Skip to content

BUGFIX: Support enums in value objects#4092

Open
mhsdesign wants to merge 1 commit intoneos:9.0from
mhsdesign:bugfix/support-enums-in-value-objects
Open

BUGFIX: Support enums in value objects#4092
mhsdesign wants to merge 1 commit intoneos:9.0from
mhsdesign:bugfix/support-enums-in-value-objects

Conversation

@mhsdesign
Copy link
Copy Markdown
Member

Followup to #4058

Before the deprecated JsonView from Flow was used which rendered enums as

{"name": "FOO", "value": "FOO"}

as enums are magically json serializable, jet dont specify to implement JsonSerializable directly.

That's way the condition is_object($value) && $value instanceof \JsonSerializable is skipped and all enum "properties" are serialized.

https://github.com/neos/flow-development-collection/blob/9e281f9fdf8490bc409038acb2f250728fb3c614/Neos.Flow/Classes/Mvc/View/JsonView.php#L270

To fix this we use plain json_encode wich encodes enums as expected without the developer having to implement JsonSerializable redundantly

"FOO"

see also https://3v4l.org/OZb1n#vnull

What I did

How I did it

How to verify it

Followup to neos#4058

Before the deprecated JsonView from Flow was used which rendered enums as

```
{"name": "FOO", "value": "FOO"}
```

as enums are magically json serializable, jet dont specify to implement `JsonSerializable` directly.

That's way the condition `is_object($value) && $value instanceof \JsonSerializable` is skipped and all enum "properties" are serialized.

https://github.com/neos/flow-development-collection/blob/9e281f9fdf8490bc409038acb2f250728fb3c614/Neos.Flow/Classes/Mvc/View/JsonView.php#L270

To fix this we use plain json_encode wich encodes enums as expected without the developer having to implement `JsonSerializable` redundantly

```
"FOO"
```

see also https://3v4l.org/OZb1n#vnull
@github-actions github-actions bot added Bug Label to mark the change as bugfix 9.0 labels Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

9.0 Bug Label to mark the change as bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant