To reproduce:

  1. Enable locale module and Content translation module
  2. Configure the site with more that one language
  3. Configure Language negotiation at admin/settings/language/configure
  4. Add a new content type with machine-readable name negotiation (or default) and configure it's Multilingual support

The language negotiation setting (language_negotiation variable) or the language default setting (language_default variable) is overwritten by the content type setting.

The patches rename the affected configuration variables in locale.module and translation.module

The variable settings for content types should have a prefix to protect the namespace, such like this:
language_content_type_*

Note: This problem may occurs in other modules where a similar approach is used to store content type settings and site-wide settings may be overwritten.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

1. Please merge the patches.
2. We need an update function to alter existing settings from Drupal 6 RC1 sites.

This is hardly critical. Critical bugs make your site go broken, this one only happens with a specific node type, with a specific config.

dropcube’s picture

1. Patches merged.
2. Update function under development.

dropcube’s picture

Title: Content types language settings overwrite site language settings if a content type name like 'negotiation'is used » Content types language settings overwrite site language settings due to conflicting configuration variable names
Status: Needs work » Needs review
FileSize
5.35 KB

The patch provides the required modifications and an update function to alter existing settings from currently installed 6 RC1 websites.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

- You use tabs in the update function, while you should use two spaces.
- There is a locale() function hunk which is already in Drupal 6.

dropcube’s picture

Status: Needs work » Needs review
FileSize
5.66 KB

- Fixed the above.
- Added notification messages to the update function to alert the users about the overwritten variables.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Getting better! I have there comments on the patch:

- we should not use t() in the update process, we use English text, so we do not rely on the localization system being in place
- if a content type name is 'default', you set an object to the variable where an integer should be possibly... you should check for the type of language_default and only set it for the content type if it is an integer, not an object (and keep the language_default setting if it is an object) IMHO
- a same issue evolved around language_negotiation, but that is an integer as well, so it makes it harder to detect... in this case, I would reset the content type setting instead, which makes no harm, not the language_negotiation setting... although as said, it is hard to tell what's in the variable at this stage if there is a 'negotiation' content type

dropcube’s picture

Status: Needs review » Needs work
FileSize
6.32 KB

Yes, you are right.

In the update function:
- If a content type name is default and the variable language_default is still and object, then it has not been overwritten by the content type setting and it's not required to update the variable, just leaves it as it is. If the variable language_default is not an object, then it is reset to is default value and the user is alerted about that.

- If a content type name is negotiation, it is not possible to detect if it has been overwritten (as you said, the variable language_negotiation is an integer in any case), so the variable language_negotiation is not reset and the variable language_content_type_negotiation is created with the current value of language_negotiation. The user is alerted about this situation.

- I have removed t(), but I am confused beacuse I saw them in system.install and thought that it could be used here.

dropcube’s picture

Status: Needs work » Needs review
Gábor Hojtsy’s picture

Status: Needs work » Needs review

This looks good code-wise (with some formatting exceptions which I can do on commit), so we just need some more testing as far as I see.

meba’s picture

Works for me and no errors occurred.

dropcube’s picture

Oh, I forgot to rename the variable name in the language selector field for nodes at locale_form_alter. Please, test this new patch. Thanks.

Gábor Hojtsy’s picture

Status: Needs review » Fixed
FileSize
6.92 KB

OK, I sat down to clean this up. Did a few things:

- merged an if() { if() {}} to if(..&&..) {}
- used NULL as default value, so we can skip missing settings
- used is_numeric(), so we can test for what we need, instead of what we don't
- used string concatenation instead of strtr() and l() with HTML formatting

Tested this with a Drupal 6 dev to Drupal 6 dev upgrade. A 'default' and a 'negotiation' content type produces lots of notices, when E_ALL is enabled, but obviously not visible on live sites without E_ALL. So this solves a namespace clashing issue well.

Committed the attached patch.

keith.smith’s picture

Status: Fixed » Needs review
FileSize
1.69 KB

Two very small typos in code comments, patch attached.

Note also that the sentence Either it is the negotiation setting or the content type setting, it is an integer. is missing a word or something.

dropcube’s picture

FileSize
1.84 KB

Ok, take a look now, English is not my native language.

dropcube’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.84 KB
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Good, committed, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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