Problem/Motivation
The core tables columns mentioned below cannot take values more than 32 characters so If a new group ID is more than 999 then upon creation of group there is fatal error that belongs to either of the two tables.
- 'menu_tree' has menu_name column varchar(32)
- 'menu_link_content' has bundle column varchar(32)
Steps to reproduce
After having 999 Groups in the System or if the next Group-ID is going to be 1000+, then when a new group is created it throws following error
Drupal\Core\Entity\EntityStorageException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'menu_name' at row 1: INSERT INTO {menu_tree} (id, menu_name) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => menu_link_content:17020a0e-7bad-4c87-a24d-34eb651a88ac [:db_insert_placeholder_1] => menu_link_content-group-menu-1141 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of /Users/qandeel/Sites/devdesktop/stedwardsd8-dev/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Proposed resolution
const MENU_PREFIX = 'menu_link_content-group-menu-';
should be shortened to
const MENU_PREFIX = 'menu_link_content-gmenu-';
or
const MENU_PREFIX = 'group_menu_link_content-';
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 3173216-12.patch | 2.41 KB | heddn |
| #8 | groupID_morethan_999_SQL_column_length_error_fix_3173216_8.patch | 2.18 KB | qandeel |
Comments
Comment #2
qandeel commentedComment #3
qandeel commentedComment #4
qandeel commentedComment #5
qandeel commentedComment #6
heddnI like,
const MENU_PREFIX = 'group_menu_link_content-';. Any other votes?Comment #7
qandeel commentedJust submitting patch in few minutes.
Comment #8
qandeel commentedComment #9
heddnComment #10
heddnWow, great work here. The update should go into post_update hook, after entities have all been adjusted.
Comment #11
heddnAlso the update should use the DB abstraction layer. The given updates isn't given to work on all the various db platforms that drupal supports.
Comment #12
heddnHere we have a conversion to a post update hook and batch support added as well. I didn't include any rewrites of the bundle, as I don't see that the bundle is anything but the default of 'menu_link_content'.
Comment #14
heddn