Commit 7175aab4 authored by Dries's avatar Dries

- Patch #668058 by andypost, mrbubbs: resubmitting a user picture does show...

- Patch #668058 by andypost, mrbubbs: resubmitting a user picture does show the first uploaded picture.
parent 574afc8e
......@@ -437,9 +437,9 @@ function user_save($account, $edit = array(), $category = 'account') {
// Prepare the pictures directory.
file_prepare_directory($picture_directory, FILE_CREATE_DIRECTORY);
$destination = file_stream_wrapper_uri_normalize($picture_directory . '/picture-' . $account->uid . '.' . $info['extension']);
$destination = file_stream_wrapper_uri_normalize($picture_directory . '/picture-' . $account->uid . '-' . REQUEST_TIME . '.' . $info['extension']);
if ($picture = file_move($picture, $destination, FILE_EXISTS_REPLACE)) {
if ($picture = file_move($picture, $destination, FILE_EXISTS_RENAME)) {
$picture->status |= FILE_STATUS_PERMANENT;
$edit['picture'] = file_save($picture);
}
......
......@@ -914,6 +914,13 @@ class UserPictureTestCase extends DrupalWebTestCase {
// Check if file is located in proper directory.
$this->assertTrue(is_file($pic_path), t('File is located in proper directory'));
// Set new picture dimensions.
$test_dim = ($info['width'] + 5) . 'x' . ($info['height'] + 5);
variable_set('user_picture_dimensions', $test_dim);
$pic_path2 = $this->saveUserPicture($image);
$this->assertNotEqual($pic_path, $pic_path2, t('Filename of second picture is different.'));
}
}
......@@ -921,11 +928,9 @@ class UserPictureTestCase extends DrupalWebTestCase {
$edit = array('files[picture_upload]' => drupal_realpath($image->uri));
$this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Save'));
$img_info = image_get_info($image->uri);
$picture_dir = variable_get('user_picture_path', 'pictures');
$pic_path = 'public://' . $picture_dir . '/picture-' . $this->user->uid . '.' . $img_info['extension'];
return $pic_path;
// Load actual user data from database.
$account = user_load($this->user->uid, TRUE);
return isset($account->picture) ? $account->picture->uri : NULL;
}
}
......
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