Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orphan records in oc_group_folders_manage are not cleaned up #2261

Open
donquixote opened this issue Feb 6, 2023 · 5 comments
Open

Orphan records in oc_group_folders_manage are not cleaned up #2261

donquixote opened this issue Feb 6, 2023 · 5 comments
Labels
1. to develop Issues that are ready for development bug

Comments

@donquixote
Copy link

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Install groupfolders app.
  2. Create a group "tempgroup".
  3. Create a user "tempuser", as member of "tempgroup".
  4. Create a group folder. Enable advanced permissions, Add the group "tempgroup" and the user "tempuser" to the advanced permission list. (This requires to first add the "tempgroup" as a group).
  5. (A) Check the contents of oc_group_folders_manage to see if it contains 'tempgroup' and 'tempuser'. Also check 'oc_groups' and 'oc_users'.
  6. Remove the user 'tempuser'.
  7. (B) Check the contents of oc_group_folders_manage to see if it contains 'tempgroup' and 'tempuser'.
  8. Remove the group 'tempgroup'.
  9. (C) Check the contents of oc_group_folders_manage to see if it contains 'tempgroup' and 'tempuser'.
  10. (D) Use the API to load the group folder, have a look at the 'manage' key in the response.

Expected behaviour

At (A), the 'tempgroup' and 'tempuser' is found in oc_group_folders_manage, oc_users and/or oc_groups, respectively.
At (B), the 'tempuser' is no longer found in either table.
At (C), the 'tempgroup' is no longer found in either table.
At (D), the response contains {manage: []}.

Actual behaviour

At (B) and (C), an orphan record for 'tempuser' still exists in oc_group_folders_manage, even though it was removed from 'oc_users'.
At (C), an orphan record for 'tempgroup' still exists in oc_group_folders_manage, even though it was removed from 'oc_groups'.
At (D), the response contains {manage: [[]]} (nested empty array).

Workaround

Currently, one way to clean up the orphan records through the API is to unset the ACL checkbox, through POST '/folders/{id}/acl' with acl=false. Then enable it again and restore the records.

Solution

The app must listen to users or groups being removed, and remove the orphan records when that happens.
I don't know how this would be done in Nextcloud, unfortunately :)

@donquixote donquixote added 0. Needs triage Issues that need to be triaged bug labels Feb 6, 2023
@donquixote
Copy link
Author

donquixote commented Feb 6, 2023

Actually there is already a listener for groups here, in OCA\GroupFolders\AppInfo\Application::boot():

	public function boot(IBootContext $context): void {
		$context->injectFn(function (IMountProviderCollection $mountProviderCollection, CacheListener $cacheListener, IGroupManager $groupManager): void {
			$mountProviderCollection->registerProvider($this->getMountProvider());

			$groupManager->listen('\OC\Group', 'postDelete', function (IGroup $group) {
				$this->getFolderManager()->deleteGroup($group->getGID());
			});
			$cacheListener->listen();
		});
	}

So all that is needed is:

  • The ->deleteGroup() method in FolderManager should also remove the respective records from group_folders_manage table.
  • In addition to listening to groups, we also need to listen to users, and have a method ->deleteUser() in FolderManager.

@blizzz blizzz added 1. to develop Issues that are ready for development and removed 0. Needs triage Issues that need to be triaged labels Aug 2, 2023
@juliusknorr
Copy link
Member

This was fixed by #2504

@donquixote
Copy link
Author

Are you sure?

In addition to listening to groups, we also need to listen to users, and have a method ->deleteUser() in FolderManager.

Is this happening?
I see a deleteCircle(), not sure what this is, but I assume not the same as a user.

@donquixote
Copy link
Author

Also I don't see test coverage. But this is up to you.

@juliusknorr
Copy link
Member

Right, sorry I missed that, let me reopen then

@juliusknorr juliusknorr reopened this Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Issues that are ready for development bug
Projects
None yet
Development

No branches or pull requests

3 participants