You are here

Drupal 7 - An Annoying Error

One error I encountered early on in D7 development was an annoying one I would get when uninstalling a custom content-type:

	Notice: Trying to get property of non-object in comment_node_type_delete()

I spent a number of hours trying to find the solution on the Drupal forums and elsewhere until I finally came across a post on Dollar Dad which had the answer. For modules with custom content-types you need to have 'base' set to 'node_content'.

// Define the node type.
$node_example = array(
	'type' => 'node_example',
	'base' => 'node_content',
	'name' => $t('Example Node'),
	'description' => $t('This is an example node type with a few fields.'),
	'body_label' => $t('Example Description'),
	'promote' => 0,

Another solution has been found

I have written a new post called Drupal 7 - An Annoying Error: Part the Second which discusses how to correct this error should using 'node_content' as your base type be an un-acceptable solution.