No Code Attached Yet bug
avatar philip-sorokin
philip-sorokin
19 Mar 2021

Is your feature request related to a problem? Please describe.

I have a module, users put into a subform field type some text in unicode. As the data is stored in JSON format (module params), its size is increasing by three times, because a json_encode function is escaping all unicode characters. My 23 KB file is becoming more than 64 KB and is not fit into limit MEDIUMTEXT. I see it's fixed in Joomla! 4, however the data is still too long.

Describe the solution you'd like

We can reduce the database size by providing an option that allows run json_encode with a flag JSON_UNESCAPED_UNICODE. If it's related to unpredictable behaviour when using globally, I suggest adding an attribute to a field, or a hook that will run json_encode with a flag JSON_UNESCAPED_UNICODE.

Additional context

Actually, I cannot see any possible issues if running json_encode in unicode mode globally. If you give some examples, when it fails, it will be sensible. I think the only reason not to use JSON_UNESCAPED_UNICODE is breaking BC with PHP5.3 that is not supported such a mode. But Joomla! 4 is not designed to cover PHP5, so it can be turned on.

avatar philip-sorokin philip-sorokin - open - 19 Mar 2021
avatar joomla-cms-bot joomla-cms-bot - change - 19 Mar 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Mar 2021
avatar brianteeman
brianteeman - comment - 19 Mar 2021

If I remember correctly then JSON_UNESCAPED_UNICODE will not work with utf8

avatar Fedik
Fedik - comment - 20 Mar 2021

I cannot see any possible issues if running json_encode in unicode mode globally

if database table will have non UTF8 collation, it will explode.
And/Or while table export/import by some tool that may break non escaped UTF symbols.

This is case when better safe than sorry.

avatar philip-sorokin
philip-sorokin - comment - 20 Mar 2021

@Fedik all Joomla! tables in utf8mb4 encoding. Some 3-party components in Joomla! 2.5 and Joomla 3 may have another encoding, but we are talking about Joomla! 4, it's not covering these components without proper encoding.

avatar richard67
richard67 - comment - 21 Mar 2021

@Fedik all Joomla! tables in utf8mb4 encoding.

Not in all scenarios. There is one valid scenario which is the reason why we still have the utf8mb4 conversion in J4. If someone is on J3.10 and migrates his or her database from an old MySQL or MariaDB server which doesn't support utf8mb4 to a newer one which does, then he or she doesn't check in "Extensions -> Manage -> Database" that there are database problems (missing utf8mb4 conversion) and updates to J4. In this case the conversion from utf8 to utf8mb4 is performed by the update to J4, so after the update it is true what you say, but not before and not during the update, and during the update the new J4 PHP code is already used when running the database updates.

avatar richard67
richard67 - comment - 21 Mar 2021

In general with database things we have to keep in mind the updating process from older versions. We can't just assume everybody runs a newly installed J4 where things may be fine, we also have to consider scenarios like the above.

avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: No Code Attached Yet bug
Removed: ?
avatar Hackwar Hackwar - labeled - 22 Feb 2023

Add a Comment

Login with GitHub to post a comment