ChangeData: Prevent false 'Merge Conflict' for user's open review

When checking for mergeability, we need to check patch visibility
because it might be a draft which is not visible to other users.

When the owner of a change loses visibility of their own change e.g.
because they are removed from a group that grants them the read
permission, reindexing the change causes the `mergeable` field of the
change info to always be set to null. As a result, when any other user
(who still has read permission on the project) views the change in the
change list, its status is shown as 'Merge Conflict'.

On the change screen, the 'Merge Conflict' is not shown. This is due
to the fact that the change screen does not use the secondary index.

Add extra logic to prevent the null `mergeable` field when the change
owner does not have access to the change.

Bug: Issue 8381
Change-Id: I4df53914b876a7e5d39aebca4d0e8c7042f5cdb0
Signed-off-by: Ardo Septama <aseptama@gmail.com>
This commit is contained in:
Ardo Septama
2018-01-31 11:35:46 +01:00
committed by David Pursehouse
parent 0f2faafdda
commit 642a79ac5a

View File

@@ -1071,7 +1071,8 @@ public class ChangeData {
}
PatchSet ps = currentPatchSet();
try {
if (ps == null || !changeControl().isPatchVisible(ps, db)) {
if (ps == null
|| (!changeControl().isOwner() && !changeControl().isPatchVisible(ps, db))) {
return null;
}
} catch (OrmException e) {