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()

Files: 
CommentFileSizeAuthor
#1 language-form-notice-1565322-1.patch2.31 KBJorrit
PASSED: [[SimpleTest]]: [MySQL] 39,737 pass(es).
[ View ]

Comments

Status:Active» Needs review
StatusFileSize
new2.31 KB
PASSED: [[SimpleTest]]: [MySQL] 39,737 pass(es).
[ View ]

Patch attached.

#1: language-form-notice-1565322-1.patch queued for re-testing.

Assigned:Jorrit» Unassigned
Status:Needs review» Reviewed & tested by the community

Bug tested and reproduced against latest 7.x-dev.
Patch solves the issue.

Version:7.x-dev» 8.x-dev
Status:Reviewed & tested by the community» Needs work
Issue tags:+needs backport to D7

Looks like the same code exists in Drupal 8 too, no?

Version:8.x-dev» 7.x-dev
Status:Needs work» Reviewed & tested by the community
Issue tags:-needs backport to D7

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.

Status:Reviewed & tested by the community» Fixed

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

Status:Fixed» Closed (fixed)

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