Commit a7ef6f36 authored by alexpott's avatar alexpott

Issue #2030551 by marcingy: Fixed PHP notice when creating new Drupal user.

parent 62551a8e
......@@ -461,13 +461,16 @@ protected function submitEntityLanguage(array $form, array &$form_state) {
foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
$previous_langcode = $form[$field_name]['#language'];
// Handle a possible language change: new language values are inserted,
// previous ones are deleted.
if ($field['translatable'] && $previous_langcode != $current_langcode) {
$form_state['values'][$field_name][$current_langcode] = $form_state['values'][$field_name][$previous_langcode];
$form_state['values'][$field_name][$previous_langcode] = array();
if (isset($form[$field_name]['#language'])) {
$previous_langcode = $form[$field_name]['#language'];
// Handle a possible language change: new language values are inserted,
// previous ones are deleted.
if ($field['translatable'] && $previous_langcode != $current_langcode) {
$form_state['values'][$field_name][$current_langcode] = $form_state['values'][$field_name][$previous_langcode];
$form_state['values'][$field_name][$previous_langcode] = array();
}
}
}
}
......
......@@ -14,6 +14,13 @@
*/
class UserCreateTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('image');
public static function getInfo() {
return array(
'name' => 'User create',
......@@ -30,6 +37,42 @@ protected function testUserAdd() {
$user = $this->drupalCreateUser(array('administer users'));
$this->drupalLogin($user);
// Create a field and an instance.
$field_name = 'test_field';
$field = array(
'field_name' => $field_name,
'module' => 'image',
'type' => 'image',
'cardinality' => 1,
'locked' => FALSE,
'indexes' => array('target_id' => array('target_id')),
'settings' => array(
'uri_scheme' => 'public',
'default_image' => FALSE,
),
);
entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field_name,
'entity_type' => 'user',
'label' => 'Picture',
'bundle' => 'user',
'description' => t('Your virtual face or picture.'),
'required' => FALSE,
'settings' => array(
'file_extensions' => 'png gif jpg jpeg',
'file_directory' => 'pictures',
'max_filesize' => '30 KB',
'alt_field' => 0,
'title_field' => 0,
'max_resolution' => '85x85',
'min_resolution' => '',
'default_image' => 0,
),
);
entity_create('field_instance', $instance)->save();
// Test user creation page for valid fields.
$this->drupalGet('admin/people/create');
$this->assertFieldbyId('edit-status-0', 0, 'The user status option Blocked exists.', 'User login');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment