Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7575641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:43:51+00:00 2026-05-30T16:43:51+00:00

I have a module job_post which installs job_post content type. In this module I

  • 0

I have a module job_post which installs job_post content type.

In this module I have hook_unistall() which calls for node_type_delete() function which removes my content type.

After unistalling process I have errors from Drupal’s core module comment which fires from node_type_delete() after module_invoke_all('node_type_delete', $info).

Error is the following and repeats 8 times (because of the loop in comment_node_type_delete()):

Notice: Trying to get property of non-object in comment_node_type_delete()
(line 343 of ....\comment.module).

I have this error because $info variable in node_type_delete() function is false.

My question is, why when my module is installed and when I’m printing var_dump(node_type_get_type('job_post')) on any page, I have an object, but when I’m trying to print the same code in my unistall function I get false and this error?

job_post.install

/**
 * Implements hook_install().
 */
function job_post_install() {
  node_types_rebuild();

  $types = node_type_get_types();
  node_add_body_field($types['job_post']);

  $body_instance = field_info_instance('node', 'body', 'job_post');
  $body_instance['type'] = 'text_summary_or_trimmed';

  field_update_instance($body_instance);
}

/**
 * Implements hook_uninstall().
 */
function job_post_uninstall() {
  $instances = field_info_instances('node', 'job_post');
  foreach ($instances as $instance_name => $instance) {
    field_delete_instance($instance);
  }

  // Force rebuild of the node type cache
  // as Clive suggested didn't help
  // _node_types_build(TRUE);

  node_type_delete('job_post');

  field_purge_batch(1000);
}

job_post.module

/**
 * Implements hook_node_info() to provide our job_post type.
 */
function job_post_node_info() {
  return array(
    'job_post' => array(
      'name' => t('Job Post'),
      'base' => 'job_post',
      'description' => t('Use this content type to post a job.'),
      'has_title' => TRUE,
      'title_label' => t('Job Title'),
      'help' => t('Enter the job title and job description')
    )
  );
}

/**
 * Implement hook_form() with the standard default form.
 */
function job_post_form($node, $form_state) {
  return node_content_form($node, $form_state);
}

Note: This module example was taken from Pro Drupal 7 Development book (page 141) with minor changes and it was given errors even with original.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:43:53+00:00Added an answer on May 30, 2026 at 4:43 pm

    Hi by referring to documentation an core modules of Drupal 7. There is a usage problem.

    hook_node_info defines a content type automatically. The content types which are created in this way, uninstalled-disable automatically.

    Core blog module defines hook_node_info but does not operate any node_type_delete on hook_uninstall

    http://api.drupal.org/api/drupal/modules%21blog%21blog.module/function/blog_node_info/7

    When you call node_type_delete('job_post'); on hook_uninstall, node type info has already gone. Because of that comments module raises error.

    Normally you should only remove any data related to your content type. And let the rest to be done by core.

    Additionally if you really want create/delete your content type, you may not use hook_node_info. You can manually create/delete content type on install/uninstall hook.

    Sample uninstall here:
    http://public-action.org/content/drupal-7-field-api-drupal-7-adding-custom-content-type-custom-fields-field-api

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have module that implements custom content type via NodeAPI hooks ( hook_insert ,
I have a module called MyApp, and another module called MyAppTests which has a
Background: I have a module which declares a number of instance methods module UsefulThings
So I have a module in flex in which I add a custom component.
I have created a Job Queue module that processes jobs and constructs social-network type
I have two content types (job_post and application) linked using the node reference +
I have a python program running using a parallel python. This module scales my
i have a query like below return this.Context.Modules .Select(p => new { Module =
I have developed a module 'newpatient' which I am unable to install through a
I have a web site module which collects some tweets from twitter and splits

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.