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

Dangling relationships after removing a working copy #77

Closed
frapell opened this issue Jul 29, 2020 · 6 comments
Closed

Dangling relationships after removing a working copy #77

frapell opened this issue Jul 29, 2020 · 6 comments

Comments

@frapell
Copy link
Member

frapell commented Jul 29, 2020

An issue exists in this product, so when you either cancel a check-out or do a check-in, the relationship between the baseline and the working copy is not removed, but instead flagged as "broken". I am not sure what was the rationale behind this implementation but it results in a broken functionality:

  1. After creating a checkout of an item, you can properly see a notification on top, between the baseline and the working copy:

Baseline
image

Working Copy
image

  1. You can either cancel the check-out or do a check-in
  2. If you now create another checkout, the notifications now look like this:

Baseline
image

Working Copy
image

The reason for this is because the relationship between them, instead of being removed, is marked as "broken"

def _deleteWorkingCopyRelation(self):
# delete the wc reference keeping a reference to it for its annotations
relation = self._get_relation_to_baseline()
relation.broken(relation.to_path)
return relation

Then, when the viewlet tries to find the relationship at

def get_checkout_relation(context):
relations = get_relations(context)
if len(relations) > 0:
return relations[0]
else:
return None
it will find several (broken) relationships, and returns the first one.

I guess one way of fixing this would be to change that get_checkout_relation so it will iterate over all relationships and at least return the first one that is not broken, however I do not see the reason nor the value on keeping relationships in a broken state, so I think the proper way to fix it is to actually remove the relationship from the catalog altogether.

@ewohnlich
Copy link

I just came across this exact issue and indeed my suggestion was going to be to modify get_checkout_relation to return the first non-broken relation instead of just assuming the first item is the intended one. Even if this package handles garbage collection better it's probably worth explicitly doing this check for any edge cases.

@frapell
Copy link
Member Author

frapell commented Aug 12, 2020

@ewohnlich Well, there are 2 things with that solution:

  1. I don't know where garbage collection is done... I believe these broken relationships are stuck in the catalog forever
  2. I don't think it is a good implementation, because to me, the state of the system should be consistent:
    a. You have an empty catalog
    b. You create a working copy
    c. You have now a relationship in the catalog
    d. You check-in or cancel the working copy

At this point, you are at the same place you were in step "a" but the catalog is in a different state, where a broken relationship exists... I have been tied up with other things and wasn't able to finish my PR here #78 I hope to be able to do so this weekend... And, btw, if you want to help me over there, you are welcome :)

@ewohnlich
Copy link

The strange thing to me is that this behavior seemed to be working in a previous version of Plone. We came across a bug where if the user deleted a wc, instead of canceling the checkout, it would cause this problem. But canceling the checkout worked as expected, so the solution was to add an event listener on deletion to call notify(CancelCheckoutEvent(ob, baseline)) if the deleted item was a working copy. Obviously that doesn't work now because canceling the checkout is itself broken. I wonder if perhaps some event listener was doing cleanup and this was altered in the recent past.

@frapell
Copy link
Member Author

frapell commented Aug 12, 2020

@ewohnlich yup, you even opened a bug 2 years ago about it #63 we also fixed that by implementing the same event subscriber... I will try to fix that too in this package in another PR

@ewohnlich
Copy link

@frapell can you explain why you think _deleteWorkingCopyRelation is involved? As far as I can tell that is only trigged on check in (merging) and not on cancelation.

@frapell
Copy link
Member Author

frapell commented Aug 12, 2020

@ewohnlich Yes, that's correct, if you check my fix in https://github.com/plone/plone.app.iterate/pull/78/files you'll see that there are 2 places where this needs to be addressed, on cancelling a checkout and on checking in... in both cases the working copy is deleted, and so the relationship should no longer exist...

There are some possible edge cases as Maurits mentioned in #78 (comment) that needs to be tested, in order to validate there are no side effects by removing the relationship, instead of marking it as broken

@jensens jensens closed this as completed in 557b9bd Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants