Problem/Motivation
The logic for field lengths is incorrect, e.g. setting a field to a max size of 64kb results in an error that says the value can't be more than 4kb.
Steps to reproduce
Add a JSON "text" field to a content type, set the limit to 64kb.
Create a node of that content type, paste in Drupal's composer.json content.
Expected behavior:
* The node saves.
Actual behavior:
* This error is shown: JSON: the text may not be longer than 4096 characters.
Proposed resolution
Fix the field length logic.
Remaining tasks
Fix the field length logic.
Add test coverage.
User interface changes
Field lengths will work correctly.
API changes
n/a
Data model changes
n/a
Comments
Comment #3
damienmckennaThis needs an update script to fix existing fields that have the wrong size.
Comment #4
damienmckennaComment #6
eric.vvf commentedComment #7
eric.vvf commentedComment #8
damienmckennaThank you for writing the update script. I converted it to a post-update script, as that's a better location for dealing with configuration.
Comment #9
damienmckennaComment #11
damienmckennaCommitted. Thank you.
Comment #14
nicholassSo Just updating today and I am getting an error from this change.
Drupal core 10.5.3
- Upgrading drupal/json_field (1.5.0 => 1.7.0)
------------ ---------------- --------------- ------------------------------------------------------------------------------
Module Update ID Type Description
------------ ---------------- --------------- ------------------------------------------------------------------------------
json_field fix_field_size post-update Empty update script to force the system to reload the field_type_categories.
------------ ---------------- --------------- ------------------------------------------------------------------------------
// Do you wish to run the specified pending updates?: yes.
> [warning] Undefined array key "type" views.views.inc:594
> [notice] Update started: json_field_post_update_fix_field_size
> [error] Failed to update field storage field_pg_jsonsettings: The SQL storage cannot change the schema for an existing field (field_pg_jsonsettings in paragraph entity) with data.
> [notice] Update completed: json_field_post_update_fix_field_size
[success] Finished performing updates.
[warning] Undefined array key "type" views.views.inc:594
Comment #15
cyxair commentedI encounter the same behavior on all Drupal 10 websites using this module.
json_field.post_update.php breaks updated on a website with existing data.
Last viable version of json_field module is 8.x-1.5.
Comment #16
damienmckennaPlease open a new issue and we'll work on this.
Comment #17
xurizaemonOpened #3553199: Invalid schema for unexpected JSON (text) field size 16384 with related issue and fix I observed upgrading from 8.x-1.4 to 8.x-1.7.