Steps to reproduce:
Site 1.
Precondition: do not configure module in any way (i.e do not set the file export path or mode)
1. Export nodes with image/file fields.
2. Create an archive of all of the files under files/ dir
Site 2.
1. Unpack the archive from above into files/ (i.e copy the files from site 1 to site 2)
2. Import the nodes (file or export code - doesn't matter)
Expected result:
Nodes and files get successfully imported
Actual result:
You get an error saying:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (filemime, filesize, status, timestamp, type, uuid) 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); Array ( [:db_insert_placeholder_0] => application/octet-stream [:db_insert_placeholder_1] => 0 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => 1349437480 [:db_insert_placeholder_4] => application [:db_insert_placeholder_5] => fa1e21a1-0f4a-8b04-d5c2-af69f16bde86 ) in drupal_write_record() (line 7013 of /DRUPAL/includes/common.inc).
resulting from the fact that the exported file object has fid field set to a certain value (taken from site 1)
and drupal_write_record checks for that and tries to update the file instead of inserting it.
A patch attached, though there were some other notices during the import process it doesn't fix:
Notice: Trying to get property of non-object in file_entity_file_update() (line 63 of /DRUPAL/sites/all/modules/contrib/file_entity/file_entity.file.inc).
or
Notice: Undefined property: stdClass::$uri in file_entity_file_presave() (line 14 of /DRUPAL/sites/all/modules/contrib/file_entity/file_entity.file.inc).
probably related to file_entity module.
Comment | File | Size | Author |
---|---|---|---|
#1 | node-export-fid-import-1804498-1.patch | 469 bytes | lex0r |
Comments
Comment #1
lex0r CreditAttribution: lex0r commentedThe patch
Comment #2
iterator CreditAttribution: iterator commentedThank you for the Patch lex0r. Worked fine for me.
Comment #3
iterator CreditAttribution: iterator commentedPlease commit this Patch to the stable version.
Comment #4
lex0r CreditAttribution: lex0r commentedThere is a workaround (looks more like an undocumented behavior) :
you have to enable "Remote export of files" on module settings page. The output produced by the module will contain 'fid' => NULL
what is exactly what was needed in my scenario.
Comment #5
kenorb CreditAttribution: kenorb commentedThe current patch didn't solve my issue reported at:
#2063121: Node Export: WD node: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri'
Comment #6
kenorb CreditAttribution: kenorb commentedRelated:
#1911638: Missing file attributes cause Integrity constraint
#1058750: Failing to import
Comment #6.0
kenorb CreditAttribution: kenorb commentedPath updated
Comment #7
danielb CreditAttribution: danielb commented(Old topic, and because of the crossover with other issues)