Commit d809b8ca authored by Drew Webber's avatar Drew Webber
Browse files

Issue #2927466 by poker10, loziju, mcdruid: "Conflicting" validators for user...

Issue #2927466 by poker10, loziju, mcdruid: "Conflicting" validators for user picture leads to confusing form error message
parent 2f9e3a15
Loading
Loading
Loading
Loading
+5 −0
Changes for modules/user/user.module: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -694,6 +694,11 @@ function user_validate_picture(&$form, &$form_state) {
    'file_validate_is_image' => array(),
    'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
    'file_validate_size' => array((int) variable_get('user_picture_file_size', '30') * 1024),
    // file_validate_is_image() uses the image toolkit to validate whether the
    // file is a valid image type, so set file_validate_extensions to an empty
    // array in order to signal to file_save_upload() that there is no need to
    // validate the upload against a default list of file extensions.
    'file_validate_extensions' => array(),
  );

  // Save the file as a temporary file.
+3 −2
Changes for modules/user/user.test: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -1313,9 +1313,10 @@ class UserPictureTestCase extends DrupalWebTestCase {
    $this->drupalLogin($this->user);

    // Try to upload a file that is not an image for the user picture.
    $not_an_image = current($this->drupalGetTestFiles('html'));
    $this->saveUserPicture($not_an_image);
    $not_an_image = $this->drupalGetTestFiles('html');
    $this->saveUserPicture($not_an_image[1]);
    $this->assertRaw(t('Only JPEG, PNG and GIF images are allowed.'), 'Non-image files are not accepted.');
    $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Additional error message not displayed.');
  }

  /**