Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When a user enters a duplicate language prefix or domain, form validation fails because those values must be unique. The validation message contains the original language that uses this prefix or domain, but the reference to this language is wrong:
if (!empty($form_state['values']['domain']) && $duplicate = db_query("SELECT language FROM {languages} WHERE domain = :domain AND language <> :language", array(':domain' => $form_state['values']['domain'], ':language' => $form_state['values']['langcode']))->fetchField()) {
form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_state['values']['domain'], '%language' => $duplicate->language)));
}
Because fetchField()
is used, $duplicate
is a string, not an object. This code fails with a message like:
Notice: Trying to get property of non-object in locale_languages_edit_form_validate()
Comment | File | Size | Author |
---|---|---|---|
#1 | language-form-notice-1565322-1.patch | 2.31 KB | Jorrit |
Comments
Comment #1
Jorrit CreditAttribution: Jorrit commentedPatch attached.
Comment #2
amontero#1: language-form-notice-1565322-1.patch queued for re-testing.
Comment #3
amonteroBug tested and reproduced against latest 7.x-dev.
Patch solves the issue.
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedLooks like the same code exists in Drupal 8 too, no?
Comment #5
Jorrit CreditAttribution: Jorrit commentedThe similar function in the Drupal 8 code base is
language_negotiation_configure_url_form_validate()
. It doesn't contain this bug, because the form has been reorganized so all prefixes/domains are configured on one page. I am therefore resetting this bug to Drupal 7.Comment #6
David_Rothstein CreditAttribution: David_Rothstein commentedStrange, I could have sworn I saw it in Drupal 8 too, but I must have still had Drupal 7 checked out when I thought I had switched over to Drupal 8. Sorry about that.
Committed to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/3e5c778