Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
299
Merge Requests
299
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
edb7ea95
Commit
edb7ea95
authored
Mar 24, 2012
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1378092
by oriol_e9g, wedge, beejeebus: Fixed User pictures are not removed properly.
parent
67235411
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
core/modules/user/user.module
core/modules/user/user.module
+4
-0
core/modules/user/user.test
core/modules/user/user.test
+44
-0
No files found.
core/modules/user/user.module
View file @
edb7ea95
...
...
@@ -456,6 +456,10 @@ function user_save($account, $edit = array()) {
file_delete
(
$account
->
original
->
picture
);
}
}
elseif
(
isset
(
$edit
[
'picture_delete'
])
&&
$edit
[
'picture_delete'
])
{
file_usage_delete
(
$account
->
original
->
picture
,
'user'
,
'user'
,
$account
->
uid
);
file_delete
(
$account
->
original
->
picture
);
}
$account
->
picture
=
empty
(
$account
->
picture
->
fid
)
?
0
:
$account
->
picture
->
fid
;
// Do not allow 'uid' to be changed.
...
...
core/modules/user/user.test
View file @
edb7ea95
...
...
@@ -1074,6 +1074,50 @@ class UserPictureTestCase extends DrupalWebTestCase {
$this
->
assertEqual
(
$pic_path
,
(
string
)
$elements
[
0
][
'src'
],
t
(
"User picture source is correct: "
.
$pic_path
.
" "
.
print_r
(
$elements
,
TRUE
)));
}
/**
* Tests deletion of user pictures.
*/
function
testDeletePicture
()
{
$this
->
drupalLogin
(
$this
->
user
);
$image
=
current
(
$this
->
drupalGetTestFiles
(
'image'
));
$info
=
image_get_info
(
$image
->
uri
);
// Set new variables: valid dimensions, valid filesize (0 = no limit).
$test_dim
=
(
$info
[
'width'
]
+
10
)
.
'x'
.
(
$info
[
'height'
]
+
10
);
variable_set
(
'user_picture_dimensions'
,
$test_dim
);
variable_set
(
'user_picture_file_size'
,
0
);
// Save a new picture.
$edit
=
array
(
'files[picture_upload]'
=>
drupal_realpath
(
$image
->
uri
));
$this
->
drupalPost
(
'user/'
.
$this
->
user
->
uid
.
'/edit'
,
$edit
,
t
(
'Save'
));
// Load actual user data from database.
$account
=
user_load
(
$this
->
user
->
uid
,
TRUE
);
$pic_path
=
isset
(
$account
->
picture
)
?
$account
->
picture
->
uri
:
NULL
;
// Check if image is displayed in user's profile page.
$this
->
drupalGet
(
'user'
);
$this
->
assertRaw
(
file_uri_target
(
$pic_path
),
"Image is displayed in user's profile page"
);
// Check if file is located in proper directory.
$this
->
assertTrue
(
is_file
(
$pic_path
),
'File is located in proper directory'
);
$edit
=
array
(
'picture_delete'
=>
1
);
$this
->
drupalPost
(
'user/'
.
$this
->
user
->
uid
.
'/edit'
,
$edit
,
t
(
'Save'
));
// Load actual user data from database.
$account1
=
user_load
(
$this
->
user
->
uid
,
TRUE
);
$this
->
assertNull
(
$account1
->
picture
,
'User object has no picture'
);
$file
=
file_load
(
$account
->
picture
->
fid
);
$this
->
assertFalse
(
$file
,
'File is removed from database'
);
// Clear out PHP's file stat cache so we see the current value.
clearstatcache
();
$this
->
assertFalse
(
is_file
(
$pic_path
),
'File is removed from file system'
);
}
function
saveUserPicture
(
$image
)
{
$edit
=
array
(
'files[picture_upload]'
=>
drupal_realpath
(
$image
->
uri
));
$this
->
drupalPost
(
'user/'
.
$this
->
user
->
uid
.
'/edit'
,
$edit
,
t
(
'Save'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment