PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'hidden' cannot be null: INSERT INTO {menu_links} .... in menu_link_save() (str 3198 file public_html/includes/menu.inc)

the error appeared after update 7.62.
when creating a new node

Comments

WiseMike created an issue. See original summary.

WiseMike’s picture

Title: error creating node - Column 'hidden' cannot be null: INSERT INTO {menu_links} » after update to 7.62 error - Column 'hidden' cannot be null: INSERT INTO {menu_links}
mrgoodfellow’s picture

Do you have any modules enabled that effect menu management?
I was unable to duplicate this issue.

When reviewing the hidden value on the table menu_links I am showing either a value of: 0, 1, or -1
I do not see any null values under 'hidden' on this table.

When adding a new menu item I am showing a value of 0 for 'hidden' on the new menu item.

Try disabling any enabled modules and see if the issue persists.

xjm’s picture

Status: Active » Postponed (maintainer needs more info)

Also, what version were you updating from? And can you provide a full backtrace?

I can't really think of a way the 7.62 or 7.63 releases themselves could have introduced a problem like this, so the most likely causes are an incomplete site update (try running update.php again and then check the status report to confirm the version is correctly set to 7.63), or a contributed or custom module.

WiseMike’s picture

Once I got corrupted table {menu_router}

I restored it from a backup. Could it be related to this error?

mrgoodfellow’s picture

@WiseMike Its possible that the table could be corrupted. If you restored from a backup and it was missing columns it could cause this.

I would suggest doing the following:

  1. Create a clean Drupal install on a fresh test environment.
  2. Install the plugins you have enabled in production.
  3. In your SQL manager, find the tables that are causing the issue (menu_router, menu_links)
  4. Compare the schema between the tables in the fresh install and your current production environment.
  5. If there are inconsistencies, such as a missing column, you need to correct them.

You could backup the correct table schema from the clean install and then use that to restore the correct schema, then re-insert your production data.
You could also manually correct any inconsistencies using SQL commands to alter the table.
https://www.w3schools.com/sql/sql_alter.asp

This is my schema for these tables in a clean install:

Table: menu_links
Columns:
menu_name varchar(32) 
mlid int(10) UN AI PK 
plid int(10) UN 
link_path varchar(255) 
router_path varchar(255) 
link_title varchar(255) 
options blob 
module varchar(255) 
hidden smallint(6) 
external smallint(6) 
has_children smallint(6) 
expanded smallint(6) 
weight int(11) 
depth smallint(6) 
customized smallint(6) 
p1 int(10) UN 
p2 int(10) UN 
p3 int(10) UN 
p4 int(10) UN 
p5 int(10) UN 
p6 int(10) UN 
p7 int(10) UN 
p8 int(10) UN 
p9 int(10) UN 
updated smallint(6)
Table: menu_router
Columns:
path varchar(255) PK 
load_functions blob 
to_arg_functions blob 
access_callback varchar(255) 
access_arguments blob 
page_callback varchar(255) 
page_arguments blob 
delivery_callback varchar(255) 
fit int(11) 
number_parts smallint(6) 
context int(11) 
tab_parent varchar(255) 
tab_root varchar(255) 
title varchar(255) 
title_callback varchar(255) 
title_arguments varchar(255) 
theme_callback varchar(255) 
theme_arguments varchar(255) 
type int(11) 
description text 
position varchar(255) 
weight int(11) 
include_file mediumtext

I hope this helps!

andyg5000’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

If it's not related to a corrupt database, my guess is that it's a contrib module that's trying load and save a menu link without proper checking. For example, I just filed #3043925: Deleted menu items can cause fatal error where taxonomy_menu was doing just that.

I'm going to close this one out, but please reopen if you don't think that's the issue!