Get this error after add a menu.
[Tue Oct 16 03:31:41.773149 2018] [proxy_fcgi:error] [pid 2240] [client 127.0.0.1:59155] AH01071: Got error 'PHP message: Uncaught PHP Exception Drupal\\Core\\Database\\IntegrityConstraintViolationException: "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'id' cannot be null: INSERT INTO {menu_tree} (id, menu_name) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array\n(\n [:db_insert_placeholder_0] => \n [:db_insert_placeholder_1] => \n)\n" at /home/203238.cloudwaysapps.com/gqcbnhmwqm/public_html/core/lib/Drupal/Core/Database/Connection.php line 683\n'
Thanks for ruining my life.
Comment | File | Size | Author |
---|---|---|---|
#6 | links-prepare-fails-on-exception-3006885-6.patch | 1.18 KB | Steven Buteneers |
Comments
Comment #2
Steven Buteneers CreditAttribution: Steven Buteneers commentedYeah I'm also getting this issue when I add a menu link with node context. Then I get this error on evert node/add page.
This makes this module completely un-usable
Comment #3
Steven Buteneers CreditAttribution: Steven Buteneers commentedComment #4
Steven Buteneers CreditAttribution: Steven Buteneers commentedAlso seeing this log just before the FATAL error:
Comment #5
Steven Buteneers CreditAttribution: Steven Buteneers commentedIt looks like this is going wrong in \Drupal\menu_token\Service\MenuTokenTreeStorage::rebuildNonDestructive
Here an array of definitions is passed in keyed by the menu link ID, each definition however contains the following keys:
- Link (the actual link).
- Config (menu token config).
The code in \Drupal\menu_token\Service\MenuTokenTreeStorage::rebuildNonDestructive doesn't take this into account, because it is looping over the definitions as if they contain only the link.
This can be seen in this snippet:
In the snippet the $link variable does not contain the link itself but is a keyed array with the config and link variable. This is where everything goes wrong.
Comment #6
Steven Buteneers CreditAttribution: Steven Buteneers commentedI found out that in \menu_token_prepare_context_replacement() an exception occurred while replacing tokens when on a node/add form. It fails because there is no actual node to use for replacement.
Because the exception occurs the following never happened:
$links[$key] = $links[$key]["link"];
Which explains the behaviour in #5.
The patch applied makes sure the links are prepared correctly.
Comment #7
vebrovski CreditAttribution: vebrovski at Agiledrop - Your Trusted Drupal Teammates commentedHi, can you write the steps to reproduce this issue so I can test it. Thanks.
Comment #8
Steven Buteneers CreditAttribution: Steven Buteneers commentedThe steps I took were:
- Install the module
- Create a menu
- Add a link in the menu that requires node context (I uses [node:url:relative])
- Add a node of any type (node/add/xxx), you will get the error.
Comment #9
DevElCuy CreditAttribution: DevElCuy at Dilygent commentedPlease somebody test and set the status of this issue to: "Reviewed & tested by community"
Comment #10
vebrovski CreditAttribution: vebrovski at Agiledrop - Your Trusted Drupal Teammates commentedHi, I tested the patch and went through debugging and it works ok. Thanks.
Comment #12
DevElCuy CreditAttribution: DevElCuy at Dilygent commentedComment #13
geek-merlin