Download & Extend

Notice in locale_languages_edit_form_validate

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

Status:active» needs review

Patch attached.

AttachmentSizeStatusTest resultOperations
language-form-notice-1565322-1.patch2.31 KBIdlePASSED: [[SimpleTest]]: [MySQL] 39,737 pass(es).View details

#2

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

#3

Assigned to:Jorrit» Anonymous
Status:needs review» reviewed & tested by the community

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

#4

Version:7.x-dev» 8.x-dev
Status:reviewed & tested by the community» needs work

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

#5

Version:8.x-dev» 7.x-dev
Status:needs work» reviewed & tested by the community

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

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

#7

Status:fixed» closed (fixed)

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

nobody click here