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.

5
  • 1
    try clearing the cache
    – msmani
    Jun 17, 2014 at 17:47
  • no that is not the solution, I have this problem like a week ago, and clear cache neither run cron worked
    – svelandiag
    Jun 17, 2014 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, 2014 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, 2014 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
    – svelandiag
    Jun 17, 2014 at 20:04

1 Answer 1

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

2
  • 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 =)
    – svelandiag
    Jun 17, 2014 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 Apr 30, 2018 at 18:53

Your Answer

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

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