2

I'm getting the integrity constraint violation error (as shown below). There indeed exists a row in file_manage table with uri=''.

So my question is can I simply delete this row entry from the table without any side affects? Additionally how this empty row could have been added here.

Error Output when I do "drush cron":


WD node: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0,                     [error

:db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
    [:db_insert_placeholder_0] => 0
    [:db_insert_placeholder_1] => 1
    [:db_insert_placeholder_2] => 1398243826
)
 in drupal_write_record() (line 7166 of D:\WORKAREA\work\htdocs\gij\includes\common.inc).

And here is the table row with empty uri:

mysql> select * from file_managed where uri='';
+------+-----+----------+-----+----------+----------+--------+------------+----------+
| fid  | uid | filename | uri | filemime | filesize | status | timestamp  | origname |
+------+-----+----------+-----+----------+----------+--------+------------+----------+
| 3356 |   0 |          |     |          |        0 |      1 | 1389353548 |          |
+------+-----+----------+-----+----------+----------+--------+------------+----------+
1 row in set (0.00 sec)
2
  • Hello. Please post code as code. <pre> works here all right. Putting <!-- language: lang-none --> in front of regular code blocks works, too. Now your first screenshot is not readable. And even if it was, putting it as image makes it impossible to find using site's search, and impossible to copy-paste for evaluation.
    – Mołot
    Commented Apr 23, 2014 at 7:52
  • Sorry .. I've updated it
    – AgA
    Commented Apr 23, 2014 at 9:07

1 Answer 1

5

You can check whether the file is being used by another part of the system with the file_usage_list() function:

$file = file_load($fid);
$usage = file_usage_list($file);

If the returned array is empty, you can probably assume that it's an orphaned record, and safe to delete. But take a backup first, as always.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.