Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option encode_options: "..." is ignored #179

Open
u07 opened this issue Nov 1, 2023 · 1 comment
Open

Option encode_options: "..." is ignored #179

u07 opened this issue Nov 1, 2023 · 1 comment

Comments

@u07
Copy link

u07 commented Nov 1, 2023

Hi!

When saving flex-objects data with JSON formatter we are allowed to set some options like file_extension, encode_options, decode_assoc, etc. The thing is, encode_options param is not handled. Example:

storage:
            class: 'Grav\Framework\Flex\Storage\FolderStorage'
            options:
                formatter:
                    class: 'Grav\Framework\File\Formatter\JsonFormatter'
                    options:
                        encode_options: 'JSON_UNESCAPED_UNICODE'  # See https://www.php.net/manual/en/function.json-encode.php
                folder: user-data://contacts

Encode options are useful when dealing with non-latin symbols, like Cyrillic. By default Cyrillic is escaped to \u123456. So the JSON looks completely gibberish:

image

Setting encode_options: 'JSON_UNESCAPED_UNICODE' (int 256) should help with that, unless it won't.

All the constants like 'JSON_UNESCAPED_UNICODE' => JSON_UNESCAPED_UNICODE are defined in 'Grav\Framework\File\Formatter\JsonFormatter', but it is never called. Instead grav\vendor\rockettheme\toolbox\File\src\JsonFile.php is used. And the encoding options are never passed to it:

image

@u07 u07 changed the title JSON formatter ignores encode_options: "..." Option encode_options: "..." is ignored Nov 1, 2023
@u07
Copy link
Author

u07 commented Dec 27, 2024

Guys, any progress? Please? I have to fix grav sources manually after every update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant