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-';

Comments

Qandeel created an issue. See original summary.

qandeel’s picture

Title: Any group created after 999 Groups Throws MYSQL error » Any group created after 999 Groups Throws MYSQL error i.e GroupID >= 1000
qandeel’s picture

Issue summary: View changes
qandeel’s picture

Issue summary: View changes
qandeel’s picture

Project: Group Menu » Group Content Menu
heddn’s picture

I like, const MENU_PREFIX = 'group_menu_link_content-';. Any other votes?

qandeel’s picture

Just submitting patch in few minutes.

qandeel’s picture

heddn’s picture

Status: Active » Needs review
heddn’s picture

Status: Needs review » Needs work

Wow, great work here. The update should go into post_update hook, after entities have all been adjusted.

heddn’s picture

Also 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.

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new2.41 KB

Here 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'.

  • heddn committed 6d3650e on 8.x-1.x
    Issue #3173216 by Qandeel, heddn: Any group created after 999 Groups...
heddn’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.