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...
Comment | File | Size | Author |
---|---|---|---|
#14 | node_type_form_validate_5.patch | 981 bytes | Pancho |
#8 | node_type_form_validate_is_botched.patch | 879 bytes | chx |
Comments
Comment #1
PanchoI can confirm this IMHO critical bug for Drupal 5.1.
Existing content type: name=yodel1, type=foo
IMHO the validation should be the other way around:
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.
Comment #2
rszrama CreditAttribution: rszrama commentedI 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.
Comment #3
rszrama CreditAttribution: rszrama commented(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.)
Comment #4
tam CreditAttribution: tam commentedI 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
Comment #5
PanchoTo clarify: These are actually not three options but three cases.
An improved outline how validation should work IMO:
I will prepare a patch ASAP. Some more opinions would be great!
By the way:
and are such grouse word constructions – I propose to call them vs. . How about that?Comment #6
BioALIEN CreditAttribution: BioALIEN commented+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.
Comment #7
mr700 CreditAttribution: mr700 commentedIsn't this one a duplicate?
Comment #8
chx CreditAttribution: chx commentedComment #9
chx CreditAttribution: chx commentedto test -> do what the original poster described.
Comment #10
John Morahan CreditAttribution: John Morahan commentedcreated 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.
Comment #11
Gábor HojtsyGood, thanks. Committed.
Comment #12
KarenS CreditAttribution: KarenS commentedThis 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.
Comment #13
drummpatching 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
Comment #14
PanchoOK, here is the same patch refactored against DRUPAL-5. Please test and rtbc.
Comment #15
drummCommitted to 5.x.
Comment #16
(not verified) CreditAttribution: commentedAutomatically closed -- issue fixed for two weeks with no activity.