Problem/Motivation
After installing the module on a site using PostgreSQL database with existing menu items we can't add menu item.
The PostgreSQL sequence menu_link_content_id_seq is corrupted by MenuLinkContentService::updateMenuLinkContentBundle().
This method backup the data from the menu_link_content table, truncate it, process field storage definition changes and then insert the backup data into the table.
After inserting the backup data the last_value of menu_link_content_id_seq sequence is update using the id of the last menu item that has been inserted.
For instance let's say we have 21 menu items.
When we retrieve the data to backup them in the array $existing_data['menu_link_content'] if we don't order them the last value in it could correspond to the 18th menu items.
The last_value of menu_link_content_id_seq is 18 and not 21 anymore.
Therefore the following error appeared when we try to add a new menu item:
SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "menu_link_content____pkey"
DETAIL: Key (id)=(19) already exists.: INSERT INTO menu_link_content (bundle, uuid, langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2);
Proposed resolution
When we retrieve the data to backup them they have to be order by id.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Todo.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | menu_item_extras-install-corrupt-sequences-3022035-2.patch | 539 bytes | beram |
Comments
Comment #2
beram commentedHere's a patch.
Comment #3
beram commentedComment #5
volegerLooks good for me. +1 for RTBC
Comment #6
kducharm commentedAnother +1 RTBC, thanks for finding this since it only seems to affect Postgresql
Comment #7
ozinComment #9
ozin