1

Well, look my problem is weird, I have a view that lists content of a desired type, it is listing all the content of a type, I have deleted from the drupal admin UI a node of that type, but the view is still listing the node I have deleted. If I try to access to that node from the view, I get an entityMetadataWrapperException

Now I cannot see the node in the drupal content admin UI.

I know the nid of this node (its 22) I need to delete it manually from the database, how to achieve this, is necesary a custom module or something?

Thank you very much for your help.

  • 1
    try clearing the cache – wolverine Jun 17 '14 at 17:47
  • no that is not the solution, I have this problem like a week ago, and clear cache neither run cron worked – SsouLlesS Jun 17 '14 at 17:52
  • I do not understand under what circumstances can a node be available in Views output even after getting deleted through admin UI. Only way i think its possible is if the output is coming from the views cache table. But you are saying clearing cache didn't help. – Ranjan Jun 17 '14 at 18:27
  • Have you done any manual SQL updates / deletes? If so, you may have an inconsistent database and a entity reference, etc, field that points to the deleted node that didn't get cleaned up properly. – mpdonadio Jun 17 '14 at 20:02
  • No I just did it through the UI, but I think the problem is that my hosting had a low php_memory_limit maybe that has something to do with this issue, however Im sure the node still exists due to I can list the node using id filtering in a vew, I did the test – SsouLlesS Jun 17 '14 at 20:04
5

You should use node_delete:

<?php
$nid='22'; // $node id , which you want to delete;
node_delete($nid);
?>

This function from the API does the necessary cleaning up when a node is deleted.

You can stick this in a custom module, or enable the PHP filter and just have it a node where you allow PHP code.

If you use the PHP Filter method, remember to disable it when done. You don't want it permanently enabled on a production site.

You may also want to repair your database, just to make sure. The screenshot below shows how to use phpMyAdmin to repair the {sessions} table. You can also use to repair the {node} table

enter image description here

  • Thank you very much this is the right answer, I just created a module that implements hook_cron and in the next run cron I could delete the node and now the view is not listing this node. Thanks =) – SsouLlesS Jun 17 '14 at 20:56
  • It doesn't look like this works if the node to be deleted contains something that crashes the server. I don't know what it is exactly that I'm dealing with because when I try to view the node I get server error 500. I need to delete it because it's causing the Search index cron process to fail – Dan Mantyla Apr 30 '18 at 18:53

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.