Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
f237c582
Commit
f237c582
authored
8 years ago
by
Lukas Reschke
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2845 from nextcloud/deleteuser-gethomeearly
Get user home folder before deletion
parents
bd20139f
91cd57e5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/User/User.php
+7
-1
7 additions, 1 deletion
lib/private/User/User.php
tests/lib/User/UserTest.php
+32
-0
32 additions, 0 deletions
tests/lib/User/UserTest.php
with
39 additions
and
1 deletion
lib/private/User/User.php
+
7
−
1
View file @
f237c582
...
...
@@ -197,6 +197,8 @@ class User implements IUser {
if
(
$this
->
emitter
)
{
$this
->
emitter
->
emit
(
'\OC\User'
,
'preDelete'
,
array
(
$this
));
}
// get the home now because it won't return it after user deletion
$homePath
=
$this
->
getHome
();
$result
=
$this
->
backend
->
deleteUser
(
$this
->
uid
);
if
(
$result
)
{
...
...
@@ -210,7 +212,11 @@ class User implements IUser {
\OC
::
$server
->
getConfig
()
->
deleteAllUserValues
(
$this
->
uid
);
// Delete user files in /data/
\OC_Helper
::
rmdirr
(
$this
->
getHome
());
if
(
$homePath
!==
false
)
{
// FIXME: this operates directly on FS, should use View instead...
// also this is not testable/mockable...
\OC_Helper
::
rmdirr
(
$homePath
);
}
// Delete the users entry in the storage table
Storage
::
remove
(
'home::'
.
$this
->
uid
);
...
...
This diff is collapsed.
Click to expand it.
tests/lib/User/UserTest.php
+
32
−
0
View file @
f237c582
...
...
@@ -200,6 +200,38 @@ class UserTest extends TestCase {
$this
->
assertTrue
(
$user
->
delete
());
}
public
function
testDeleteWithDifferentHome
()
{
/**
* @var Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
$backend
=
$this
->
createMock
(
Dummy
::
class
);
$backend
->
expects
(
$this
->
at
(
0
))
->
method
(
'implementsActions'
)
->
will
(
$this
->
returnCallback
(
function
(
$actions
)
{
if
(
$actions
===
Backend
::
GET_HOME
)
{
return
true
;
}
else
{
return
false
;
}
}));
// important: getHome MUST be called before deleteUser because
// once the user is deleted, getHome implementations might not
// return anything
$backend
->
expects
(
$this
->
at
(
1
))
->
method
(
'getHome'
)
->
with
(
$this
->
equalTo
(
'foo'
))
->
will
(
$this
->
returnValue
(
'/home/foo'
));
$backend
->
expects
(
$this
->
at
(
2
))
->
method
(
'deleteUser'
)
->
with
(
$this
->
equalTo
(
'foo'
));
$user
=
new
User
(
'foo'
,
$backend
);
$this
->
assertTrue
(
$user
->
delete
());
}
public
function
testGetHome
()
{
/**
* @var Backend | \PHPUnit_Framework_MockObject_MockObject $backend
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment