Skip to content

Commit 2dbd082

Browse files
authored
Merge pull request #8198 from 4teamwork/es/TI-1633-fix-close-remote-task
Skip duplicate state transition when predecessor task is already closed
2 parents bcd89b9 + d91c908 commit 2dbd082

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

changes/TI-1633.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip duplicate state transition if completing successor task. [elioschmutz]

opengever/task/browser/complete_utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from opengever.tabbedview.helper import linked
88
from opengever.task import _
99
from opengever.task import util
10+
from plone import api
11+
from StringIO import StringIO
1012
from z3c.relationfield import RelationValue
1113
from zope.app.intid.interfaces import IIntIds
1214
from zope.component import getUtility
@@ -113,6 +115,26 @@ def complete_task_and_deliver_documents(
113115
linked(doc, doc.Title()),
114116
_(u'label_related_items', default=u"Related Items"))
115117

118+
if api.content.get_state(task) == predecessor.review_state:
119+
# If the successor task is already in the same state as the predecessor
120+
# (e.g. both are closed), we skip changing the predecessor's state.
121+
#
122+
# This situation can occur after a conflict error during the initial
123+
# commit of the local transition. The transaction manager retries the
124+
# request, but the remote task may already have been closed and committed
125+
# to the OGDS. This is usually not an issue, but it's possible that
126+
# the current user does no longer have permission to access the predecessor
127+
# task, which would lead to an Unauthorized error and the local transition
128+
# would be aborted. Means, the predecessor remains closed, but the local
129+
# successor task is still open and cannot be closed anymore.
130+
#
131+
# When the retry attempts to close the local task again, we
132+
# detect that the predecessor is already closed as well and avoid
133+
# performing the transition on the remote admin unit a second time.
134+
#
135+
# Fixes https://4teamwork.atlassian.net/browse/TI-1633
136+
return StringIO('OK')
137+
116138
request_data = {'data': json.dumps(data)}
117139
response = dispatch_request(
118140
predecessor.admin_unit_id,

0 commit comments

Comments
 (0)