I'm quite new with Drupal 7 development, after researching and following some tutorials I was able to create my custom module that defines a new node type with some fields, but now I have a problem when I uninstall it, the hook_uninstall runs almost fine(the node type, the contents from my custom node, and the node fields), except that display this error after the uninstall:
Notice: Trying to get property of non-object en comment_node_type_delete() (línea 344 de /opt/lampp/htdocs/drupal/modules/comment/comment.module). Notice: Trying to get property of non-object en comment_node_type_delete() (línea 355 de /opt/lampp/htdocs/drupal/modules/comment/comment.module). Notice: Trying to get property of non-object en comment_node_type_delete() (línea 355 de /opt/lampp/htdocs/drupal/modules/comment/comment.module). Notice: Trying to get property of non-object en comment_node_type_delete() (línea 355 de /opt/lampp/htdocs/drupal/modules/comment/comment.module). Notice: Trying to get property of non-object en comment_node_type_delete() (línea 355 de /opt/lampp/htdocs/drupal/modules/comment/comment.module). Notice: Trying to get property of non-object en comment_node_type_delete() (línea 355 de /opt/lampp/htdocs/drupal/modules/comment/comment.module). Notice: Trying to get property of non-object en comment_node_type_delete() (línea 355 de /opt/lampp/htdocs/drupal/modules/comment/comment.module). Notice: Trying to get property of non-object en comment_node_type_delete() (línea 355 de /opt/lampp/htdocs/drupal/modules/comment/comment.module).
This is from mymodule.install:
function mynode_uninstall() {
$ournewtype = 'mynode';
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(':type' => $ournewtype));
$nodeids = array();
foreach ($result as $row) {
$nodeids[] = $row->nid;
}
node_delete_multiple($nodeids);
node_type_delete($ournewtype);
field_purge_batch(500);
drupal_flush_all_caches();
}