Posted by Jorrit on May 7, 2012 at 9:25am
4 followers
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | locale.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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:
<?php
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()
Comments
#1
Patch attached.
#2
#1: language-form-notice-1565322-1.patch queued for re-testing.
#3
Bug tested and reproduced against latest 7.x-dev.
Patch solves the issue.
#4
Looks like the same code exists in Drupal 8 too, no?
#5
The 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.#6
Strange, 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
#7
Automatically closed -- issue fixed for 2 weeks with no activity.