Drupal 7 Upgrade Issue, PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘fid’ cannot be null

One of the issue arises after the drupal 7 upgradation is: when a new node is created and no value i

One of the issue arises after the drupal 7 upgradation is: when a new node is created and no value is supplied to an included media embed field in the content type the following error is generate:

Notice: Undefined property: stdClass::$fid in file_usage_add() (line 685 of ——– includes/file.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘fid’ cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => file [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => 1772 [:db_insert_placeholder_4] => 1 ) in file_usage_add() (line 692 of ————–/includes/file.inc)

The new node created OK but no content is saved on the node. If a value is supplied then node saves fine and no error.

Basically the field exists as a entity type of “file” after being carried over after a drupal 6 to 7 upgrade and the original media content type being “content migrated” – the entity type remains as “file” instead of “media”

Quick solution for this is to follow the bellow steps:

  • Go to Structure->Content Type->manage Field
  • Change the field widget to Embedded Media Field
  • Delete the default value for the field
  • Change the field widget back to Media File Selector

Leave a Reply

Your email address will not be published. Required fields are marked *

3  ×  2  =