I am having a problem with these PDO Exception errors, the first one was a collation problem between utf8 unicode vs utf8 general. I fixed that issue by running a script I found in one of the threads to change the db collation and updated all of my tables. Now I am getting this problem whenever I try to add a menu link to the main menu. The complete error message is:

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'router_path' doesn't have a default value: INSERT INTO {menu_links} (menu_name, plid, link_path, hidden, external, has_children, expanded, weight, module, link_title, options, customized, updated) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12); Array ( [:db_insert_placeholder_0] => main-menu [:db_insert_placeholder_1] => 0 [:db_insert_placeholder_2] => node/8 [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => 0 [:db_insert_placeholder_8] => menu [:db_insert_placeholder_9] => Town History [:db_insert_placeholder_10] => a:0:{} [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => 0 ) in menu_link_save() (line 3001 of /home/ftgchamb/public_html/main/includes/menu.inc).

The problem seems to be with the database expecting a value and not recieveing one? I am not sure if this is a core issue but seems to be since I am creating a basic page and adding a menu link. On my dev machine I had everything working properly with core 7.6 but I am now trying to migrate to the live website with 7.7. Could really use some help on this one.

CommentFileSizeAuthor
#5 dbfix.txt3.14 KBnzxt
#5 showCreatemenu_links.txt3.47 KBnzxt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bleen’s picture

Status: Active » Closed (duplicate)

IGNORE THIS ... I misread

bleen’s picture

Status: Closed (duplicate) » Active
nzxt’s picture

Anyone have any information on the PDOException errors? What does this pertain to? Is this a database collation error or does this have to do with malformed code? Trying to work through this but need some insight.

catch’s picture

Category: bug » support
Priority: Critical » Major
Status: Active » Postponed (maintainer needs more info)

{menu_links}.router path has a default value of '', see
http://api.drupal.org/api/drupal/modules--system--system.install/functio...

     'router_path' => array(
        'description' => 'For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.', 
        'type' => 'varchar', 
        'length' => 255, 
        'not null' => TRUE, 
        'default' => '',

Please run the output of SHOW CREATE TABLE menu_links; on your Drupal install.

Alternatively you could try installing http://drupal.org/project/schema and compare with that. I've not tried that module for D7 yet.

This looks like a site-specific issue so I'm moving it to a support request for now.

Is the script you ran from Drupal.org somewhere or just a generic one for changing collation?

nzxt’s picture

FileSize
3.47 KB
3.14 KB

Regarding the script I ran it is just a generic php script that generates the mysql commands to change collations on db tables. The script was linked to in a drupal thread, http://drupal.org/node/470304. Attached is the php script I used. Also attached is the mysql output from SHOW CREATE menu_links. Im not sure exactly what to look for there.

I installed the schema module, it gave these notices when I went to configuration page after enabling the module:
Warning message
•Field field_data_field_event_date.field_event_date_value: no Schema type for mysql type datetime.
•Field field_data_field_event_date.field_event_date_value2: no Schema type for mysql type datetime.
•Field field_revision_field_event_date.field_event_date_value: no Schema type for mysql type datetime.
•Field field_revision_field_event_date.field_event_date_value2: no Schema type for mysql type datetime.
•field_data_field_event_date.field_event_date_value: no type for Schema type datetime:normal.
•Field field_data_field_event_date.field_event_date_value: no Schema type for type datetime.
•field_data_field_event_date.field_event_date_value2: no type for Schema type datetime:normal.
•Field field_data_field_event_date.field_event_date_value2: no Schema type for type datetime.
•field_revision_field_event_date.field_event_date_value: no type for Schema type datetime:normal.
•Field field_revision_field_event_date.field_event_date_value: no Schema type for type datetime.
•field_revision_field_event_date.field_event_date_value2: no type for Schema type datetime:normal.
•Field field_revision_field_event_date.field_event_date_value2: no Schema type for type datetime.

I am unable to access the schema functions, documentation says it should be under structure -> schema but it not there. So as now I am unable to do the comparision with schema.

It seems my databse is out of wack. At this point I really hate to say it but I am thinking about doing a clean install with clean database. I don't want to resort to that so maybe somebody can see something I am missing. If I do go that route how could I ensure that my databse doesn't get trashed again? Kind of a deviation because I would rather fix what I have if at all possible.

catch’s picture

Priority: Major » Normal
Status: Postponed (maintainer needs more info) » Fixed

So the issue is this:

  `router_path` varchar(255) NOT NULL,

On a stock D7 install on my system it's this:


  `router_path` varchar(255) NOT NULL DEFAULT '' COMMENT 'For links corresponding to a Drupal path (external = 0), this connects the link to a menu_router.path for joins.',

Looking at the script you posted it has this section:

  
  if ( $row['Null'] == 'YES' )
   $nullable = ' NULL ';
  else
   $nullable = ' NOT NULL ';
  // Does the field default to null, a string, or nothing?
  if ( $row['Default'] === NULL && $row['Null'] == 'YES' )
   $default = " DEFAULT NULL ";
  elseif ( $row['Default'] != '' )
   $default = " DEFAULT '".mysql_real_escape_string($row['Default'])."'";
  else
   $default = '';
  // sanity check and fix:
  if ($nullable == ' NOT NULL ' && $default == ' DEFAULT NULL ') {
   $default = '';

This looks pretty broken to me. So what's happened is the script has corrupted your database to have a completely different schema to the one Drupal requires, instead of just changing the collation.

You'll need to either restore a backup of the db, or start again. Another option is to backup, do a clean install, then try to import the data (but not the table definitions) from a database dump - that might work fine.

I'm going to mark this fixed since I think we identified what the problem is and there's no core bug to fix.

nzxt’s picture

Awesome thanks. I can see how it is chaning the schema now, wish I would have know what to look for before I ran the script. I could have saved myself several hours of digging through threads and my files. I do have a backup from before I ran the script but it has the illegal mix of collations error. I will just try it and see how it goes.

Again thanks for the help.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

typo

DocDJ-forum’s picture

First, let me apologize if this is not the proper place to report this problem. If it isn't can someone please give me a link where I should report it?

I recently exported my Drupal DB and imported it on another system. The new site works, except I get the PDO error when I try to perform admin tasks, such clicking on the Content tab or try to "configure block". If I try to "edit block", I do not get this error. I am using Drupal 7.51. I have NO local code . I only have supported Drupal add-ins. I have tried to switch to Non-strict mode which did not help. I have also tried to delete and re-import the DB. The OLD system is currently unavailable (hardware failures), so I can't currently re-export. I am using MySQL 5.7.23.

DocDJ-forum’s picture

I was fortunate to still have my original site in working condition. So this solution https://www.drupal.org/node/1428176 worked for me. I just examined the 2 databases (in my case, using phpmyadmin) looking for the tables/fields with the "bad" initial values and made the new DB match the old DB. I used the "manual" method because I did not want to muddy the waters with anything that update.php might do in the "fast" method. I only needed steps 7-10 and it took me 2 minutes for the 2 tables causing trouble.