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:
"The website encountered an unexpected error. Please try again later."
and the following exception is logged.
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] => 1350 [:db_insert_placeholder_4] => 1 ) in file_usage_add() (line 664 of D:\websites\globalengaged7\includes\file.inc).
The new node created OK
If a value is supplied then node saves fine and I dont see the error.
The field by the way is marked as not required.
Comments
Comment #1
martynpanes commentedGot to the bottom of this - 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"
Comment #2
martynpanes commentedComment #3
martynpanes commentedlkklkl
Comment #4
freelock@Martynpanes how did you resolve this? I think I'm hitting the same issue, site upgraded D6 to D7, can't post new articles without adding media to an optional field, get this error. How did you set the entity type to fix this?
Comment #5
freelockFor posterity: in our case, field had a default value set, but there was no UI for the media selector or file widgets for setting/changing default values.
To fix, I set the widget to Embedded Media, deleted the default value that appeared, and then set the widget back.
Comment #6
drupalninja99 commented#5 worked for me, thanks!
Comment #7
fadgadget commentedhello i have the same problem with a video file that i converted D6 to D7. Finding it hard to follow the above. This part-
What default value should i be deleting? I dont see anything to delete. Just when i thought i had managed to finally migrate this has thrown me.
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] => 15060 [:db_insert_placeholder_4] => 1 ) in file_usage_add() (line 661 of /home/onlineba/public_html/includes/file.inc).my field settings-
Thanks :hope
Comment #8
fadgadget commentedsorted :) I missed the part about enabling embedded media field module. I changed my field widget to this and then noticed that i had the 'require this field' checkbox ticked. I unticked this and then changed the widget back as freelock suggested and all working fine. phew
Comment #9
13rac1 commentedMy steps to correct:
Comment #10
krisrobinson commentedThank you for #9. Worked for me.
Comment #11
scottybrookie commented#5 and #9 fixed the problem for me as well. Thank you.
Comment #12
couloir007 commentedI've followed these steps, in fact I've done this on another site with success, but this time around I follow the directions but no Embedded Media Field is available. I've trie uninstalling and reinstalling with no success. Much searching turns up nothing.