Create a module containing a field type of editor.
Using this module, enter any content which exceeds 65535 characters.
An admin would expect it just to save all the content, but realistically a warning saying you cannot enter that much content, and the ability to edit down accordingly would seem sensible.
An "Error decoding JSON data" error appears on both the front and back end of the site (when you try and edit the module, or view it on the front). The module cannot then be accessed via the admin, and if you go into the database you notice that the JSON string is incomplete, as it has only saved the first 65535 characters.
I suspect what is required is to validate the json string for length before adding it to the database.
I tried using the customContent method of adding data. This doesn't break as seriously (as it does not use json), but any additional characters are also cropped.
Labels |
Added:
?
|
Heheh. It was actually an admin copy-pasting an image which triggered it - the editor converts that to base64 (which uses a lot of characters).
This happened to one extension of mine too.
Saving editor contents in a single JSON database field it's not so difficult that users exceed that 65535 bytes limit.
I had to include a check into my extension to prevent saving and warn the user in this situation, indeed being this field used by a system plugin, the result was a disaster. The entire website frontend/backend was likely to be unreachable showing "Error decoding JSON data" error
If you submitted a PR then everyone would benefit
Labels |
Added:
J3 Issue
|
Status | New | ⇒ | Discussion |
This is a repeat of the usual "X field in Y table should be changed from TEXT to LONGTEXT because I'm trying to store too much data into this database column" request, only I think this might be the first for #__modules.content
(usually it's the #__extensions
or #__template_styles
tables, though I also vaguely remember one issue in the past because people someone was trying to do full articles in modules instead of using com_content).
I don't think it should be changed to LONGTEXT - it's ultimately a mistake to add that much text. The bug I'm reporting is that it breaks the site rather than fails gracefully, due to the field containing a JSON string which is not being validated for its length and so becomes invalid when it doesn't save properly.
Admins always do unexpected things they they need to be told not to - massive images etc, but to be able to actually break the site doing something unwise but understandable (pasting an image into the editor in this case) seems like a bug that needs fixing.
It could perhaps be argued that the issue is TinyMCE converting pasted images to base64, I suppose. The result is the same.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-04-18 17:34:18 |
Closed_By | ⇒ | franz-wohlkoenig |
Closed as having Pull Request.
Why on earth are you putting war and peace in a module?