Node type disappears if its "type" has already been used (same orig_type)

Created on 10 July 2009, about 15 years ago
Updated 18 April 2024, 5 months ago

Scenario: rename the "type" of a node type, such that the new "type" is alphabetically after the original. Create a new node type whose machine "type" is the same as the original type of the one that has been renamed.

This node type is not listed on the Create content page, nor can it be edited/deleted etc.

The culprit looks to be http://api.drupal.org/api/function/_node_types_build/6 which at the bottom has

      if ($type_object->type != $type_object->orig_type) {
        unset($_node_types[$type_object->orig_type]);
        unset($_node_names[$type_object->orig_type]);
      }

TBH I'm not sure what this code is trying to achieve. It went in to Drupal 5 as part of the patch that gave us configurable node types (http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/node/node.module?v..., #62340: Pave the way for CCK ). I've had a quick look through that issue but it would take a bit of time to track down the rational, if stated there.

I wonder if simply removing these lines would work? What would it break? In my case I have a node type currently of type "event_0" that originally had type "event" (yeah, the one created by event.module, that s.o. else installed on the site ;-) ). Had kind of forgotten about it and created a new type "event". What makes this all particularly nasty is that it is only because my new type "event" gets processed before "event_0" that the latter is able to trash it. And if I rename "event_0" to come alphabetically before "event" then indeed my new type does show up, after clearing caches.

Problem also appears to affect 5.x and 7.x.

🐛 Bug report
Status

Needs review

Version

7.0 ⚰️

Component
Node system 

Last updated 1 minute ago

No maintainer
Created by

🇬🇧United Kingdom gpk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024