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

Refactor favorite and user list tag unlinking. #3807

Merged
merged 7 commits into from
Jun 17, 2024

Conversation

demiankatz
Copy link
Member

@demiankatz demiankatz commented Jun 13, 2024

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.

@demiankatz demiankatz added the architecture pull requests that involve significant refactoring / architectural changes label Jun 13, 2024
@demiankatz demiankatz added this to the 10.0 milestone Jun 13, 2024
$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);
Copy link
Member Author

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.

Copy link
Contributor

@EreMaijala EreMaijala left a 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.

@demiankatz demiankatz removed the request for review from aleksip June 17, 2024 19:44
@demiankatz demiankatz merged commit cce247f into vufind-org:dev Jun 17, 2024
7 checks passed
@demiankatz demiankatz deleted the destroy-links-refactor branch June 17, 2024 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture pull requests that involve significant refactoring / architectural changes
Projects
None yet
2 participants