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/

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/


Notice: Undefined property: stdClass::$uri in file_entity_file_presave() (line 14 of /DRUPAL/sites/all/modules/contrib/file_entity/

probably related to file_entity module.

#1 node-export-fid-import-1804498-1.patch469 byteslex0r


lex0r’s picture

The patch

iterator’s picture

Thank you for the Patch lex0r. Worked fine for me.

iterator’s picture

Please commit this Patch to the stable version.

lex0r’s picture

Priority: Major » Normal

There 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.

kenorb’s picture

kenorb’s picture

kenorb’s picture

Issue summary: View changes

Path updated

danielb’s picture

Status: Needs review » Closed (outdated)

(Old topic, and because of the crossover with other issues)