1. Create a new content type: name = yodel1, type = foo
-> When you click the "submit" button the message "The content type yodel1 has been added." is displayed. So far so good...
2. Create another new content type: name = yodel2, type = foo
-> When you click the "submit" button the message "The content type yodel2 has been updated." is displayed.

Huh? I would expect the system to warn me that another content type "foo" already exists and instruct me that I must choose a different type. Instead, the first content type is unexpectedly overwritten by the second content type.

Create yet another new content type: name = yodel2, type = bar
-> When you click the "submit" button the message "The human-readable name foo is already taken." is displayed.

I conclude that the check against overwriting indeed takes place, but the check by mistake is made on the human-readable name instead of the machine-readable type.

I have experienced the bug on a 5.1 installation that was just upgraded from 4.7.

Note: I'm not sure whether I have assigned this report to the correct component...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pancho’s picture

Priority: Normal » Critical

I can confirm this IMHO critical bug for Drupal 5.1.

Existing content type: name=yodel1, type=foo

  1. New content type: name=yodel1, type=foo => is accepted and updates existing type
  2. New content type: name=yodel2, type=foo => is accepted and updates existing type
  3. New content type: name=yodel1, type=foo2 => is not accepted and leads to an error message

IMHO the validation should be the other way around:

  1. should lead to an error message: "The human-readable-name yodel1 already exists."
  2. should lead to an error message: "The machine-readable-name foo already exists."
  3. should lead to a confirmation message: "Another nodetype with the human-readable-name yodel1 already exists. Do you really want to create another nodetype with the same human-readable-name?"

Why do we want option 3 to be possible? Someone could want to have different nodetypes enabled for different roles but call them by the same human-readable name.
Why do we want the confirmation message then? Most people will do this accidentally and should be warned.

rszrama’s picture

I can confirm the bug that leads to the update message when you create a second content type with a different human-readable name but the same machine-readable name. I disagree with Pancho on his solution's steps 1 and 3, for the same reason he gave for having an option 3.

Since the human readable name only applies to display, I don't see why there should be any duplication checking at all. It's the internal, machine-readable name that needs to be unique for code purposes. What the display name is of the node type should have no bearing on anything else...

To differentiate between them on that add content list, it should be left up to the site administrator to specify the difference between the two types in their descriptions.

rszrama’s picture

(To clarify, I would say keep Pancho's option 2. Only fail validation on a duplicate machine-readable name. Don't show any message otherwise.)

tam’s picture

I agree this is a crucial bug. I have just created a 'book review' content type and unfortunately chose 'book' as it's machine name. Agh! Now I have no 'book page' option on the create content list. How to correct the errors stemming from this bug? I am using 5.1

Pancho’s picture

Assigned: Unassigned » Pancho

To clarify: These are actually not three options but three cases.

An improved outline how validation should work IMO:

  1. must throw an error message like:
    Nodetype foo already exists. Please choose another machine-readable name.
  2. must throw an error message like:
    Nodetype foo already exists. Please choose another machine-readable name.
  3. IMHO should lead to a confirmation message like:
    Another nodetype with the human-readable-name yodel1 already exists. Do you really want to create another nodetype with the same human-readable-name?

I will prepare a patch ASAP. Some more opinions would be great!

By the way: human-readable-name and machine-readable-name are such grouse word constructions – I propose to call them display name vs. internal name. How about that?

BioALIEN’s picture

Version: 5.1 » 6.x-dev

+1 for finding this bug. However, all such modifications need to be applied to HEAD first and then ported down to D5.x

1) Confirm that this is the case with Drupal HEAD branch, if its the case, then you can start your patch for the D6.x branch.
2) I disagree with the logic behind validation 3. You can't have 2 content types of the same name - even if they're from different machine names. It's a cause for concern and confusion - if you want to link it to roles etc, then this is a special case and should not be made for core.

So IMHO, stick to validation 1 & 2 routines only. A solid and reliable core is better.

mr700’s picture

Isn't this one a duplicate?

chx’s picture

Assigned: Pancho » chx
Status: Active » Needs review
FileSize
879 bytes
chx’s picture

to test -> do what the original poster described.

John Morahan’s picture

Status: Needs review » Reviewed & tested by the community

created yodel1 / foo => no problem.
tried to create yodel2 / foo => The machine-readable name foo is already taken.
tried to create yodel1 / bar => The human-readable name yodel1 is already taken.
created yodel2 / bar => no problem.
tried to create yodel1 / foo again => both error messages appear.
admin/content/types/foo -> save => no problem.
admin/content/types/foo -> change to yodel1 / bar => The machine-readable name bar is already taken.
admin/content/types/foo -> change to yodel2 / foo => The human-readable name yodel2 is already taken.
admin/content/types/foo -> change to yodel2 / bar => both error messages appear.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Good, thanks. Committed.

KarenS’s picture

Version: 6.x-dev » 5.x-dev
Status: Fixed » Patch (to be ported)

This needs to be fixed in 5.x, too. This has been reported several times on the CCK issue queue for 5.x by people who assume it is CCK doing this.

drumm’s picture

patching file modules/node/content_types.inc
Hunk #1 FAILED at 223.
Hunk #2 succeeded at 245 (offset 3 lines).
1 out of 2 hunks FAILED -- saving rejects to file modules/node/content_types.inc.rej

Pancho’s picture

Status: Patch (to be ported) » Needs review
FileSize
981 bytes

OK, here is the same patch refactored against DRUPAL-5. Please test and rtbc.

drumm’s picture

Status: Needs review » Fixed

Committed to 5.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.