1

I have a content type "event" which has an image field.
I tried to deleted the nodes, but I got the repeated errors when deleted the nodes.

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of D:\xampp\htdocs\mysite\includes\entity.inc).

I did not use any hook to delete nodes. I just deleted the nodes from the page "admin/content" by selecting "Delete selected nodes" in the UPDATE OPTIONS.

I checked the node related tables including field tables and I found that they were deleted as expected. When I tried to query the file tables, I found that some records were not deleted and the files in the file directory were not deleted too.

BEFORE DELETE

mysql> select * from file_usage where id = 41 order by fid;
+--+--+--+--+--+--+--+--+--+--+--+--+--++
| fid | module      | type | id | count |
+--+--+--+--+--+--+--+--+--+--+--+--+--++
| 30  | file        | node | 41 | 1     |
| 31  | file        | node | 41 | 1     |
| 32  | file        | node | 41 | 1     |
| 172 | file        | node | 41 | 1     |
+--+--+--+--+--+--+--+--+--+--+--+--+--++

mysql> select fid, filename, uri from file_managed where fid in (30,31,32,172);
+-----+------------------------------------+-----------------------------------------------+
| fid    | filename                        | uri                                           |
+-----+------------------------------------+-----------------------------------------------+
|    30  | Festival.jpg                    | public://Festival_0.jpg                       |
|    31  | Festival.jpg                    | public://Festival_1.jpg                       |
|    32  | Festival.jpg                    | public://Festival_2.jpg                       |
|    172 | Festival_465x350.jpg            | public://Festival_465x350_0.jpg               |
+-----+------------------------------------+-----------------------------------------------+

AFTER DELETE

mysql> select count(*) from node where type = 'event';
+----------+
| count(*) |
+----------+
| 0        |
+----------+

mysql> select * from file_usage where id = 41 order by fid;
+--+--+--+--+--+
| fid | module | type | id | count |
+--+--+--+--+--+
| 30 | file | node | 41 | 1 |
| 31 | file | node | 41 | 1 |
| 32 | file | node | 41 | 1 |
+--+--+--+--+--+

mysql> select fid, filename, uri from file_managed where fid in (30,31,32);
+-----+---------------------+-------------------------------+
| fid    | filename         | uri                           |
+-----+---------------------+-------------------------------+
|    30  | Festival.jpg     | public://Festival_0.jpg       |
|    31  | Festival.jpg     | public://Festival_1.jpg       |
|    32  | Festival.jpg     | public://Festival_2.jpg       |
+-----+------------------------------------+----------------+

They became orphan. What could that be why they are not deleted as expected?
Is there any fix for this? My Drupal version is 7.15.

  • I'm sure the node id 41 in my example is the event nid :) – Sithu Dec 11 '12 at 6:51
  • I think it would be because of broken links in my site. Thanks for any help. – Sithu Dec 17 '12 at 3:15
1

Incidentally, I got this error yesterday ;-) And after a bit of searching and looking into the documentation, I found that the cause was the functions which loads entities in Drupal and with the name like something_load(e.g. node_load()). I was using node_load() function to load the node and then delete it using node_delete_multiple().

This error was caused because, I was passing array as an argument to node_load(), by something like user_load(array("...; which is not the right way to do it.
The argument to anything_load() function must be a single id. So, you can search for the _load functions which uses array as an argument in your code.

  • I did not use any hook to delete nodes. I just deleted the nodes from the page "admin/content" by selecting "Delete selected nodes" in the UPDATE OPTIONS. – Sithu Dec 11 '12 at 6:43
  • @Sithu This is strange! I'm afraid, I've never come across such use-case, so couldn't be of much help. But, if you are sure about the nid of the node you're wishing to delete, then you could try to use node_delete() or node_delete_multiple(as mentioned in the answer), to delete the node. – AjitS Dec 11 '12 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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