summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-07-17 11:30:01 +0000
committerDries Buytaert <dries@buytaert.net>2010-07-17 11:30:01 +0000
commit7175aab4f9a7740c2657341fe249b3a4b16abcfa (patch)
treeff258e2876ba6930daa7d6e122be5479814b9ff7
parent574afc8e9e633468c019d2eaf344794d69a75dfb (diff)
downloadbrdo-7175aab4f9a7740c2657341fe249b3a4b16abcfa.tar.gz
brdo-7175aab4f9a7740c2657341fe249b3a4b16abcfa.tar.bz2
- Patch #668058 by andypost, mrbubbs: resubmitting a user picture does show the first uploaded picture.
-rw-r--r--modules/user/user.module4
-rw-r--r--modules/user/user.test15
2 files changed, 12 insertions, 7 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 226f2f152..c07aa1461 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -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);
}
diff --git a/modules/user/user.test b/modules/user/user.test
index 392a2cb52..da6443585 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -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;
}
}