-
Notifications
You must be signed in to change notification settings - Fork 351
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
Refactor favorite and user list tag unlinking. #3807
Conversation
$userResource->destroyLinks(null, $list->getUser()?->getId(), $list->getId()); | ||
// Remove user_resource and resource_tags rows for favorites tags: | ||
$listUser = $list->getUser(); | ||
$this->resourceTagsService->destroyResourceTagsLinksForUser(null, $listUser, $list); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the destroyLinks() method was automatically calling the tag destruction method. It seemed safer to separate these things for clarity; since we now encapsulate the functionality within FavoritesService, this seemed reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving; the transaction support is not a showstopper and could be revisited later.
This is the last significant piece of database refactoring required for the 10.0 release!
When reviewing the old tag cleanup code, I realized that it's very prone to race conditions and problems, so I simply deprecated it all. I added transactions around the "create tag and link tag to favorites" operations so that we avoid the race condition where a tag gets created and then deleted as an orphan before it can be linked up. I also inserted my recently-added orphan cleanup operation after major delete operations. I opted not to put it in the places where we delete tag lists before rewriting them, since I was concerned that might cause performance issues; I figure if we leave some orphaned tags lying around for a little while, it won't hurt, and they will get cleaned up sooner or later. We could add a command line utility to purge orphans as well if we're really worried about it.