Fix: 'query disabled' error
All groups run smoothly with the default value of the 'Query Limit'
global capability, but once one group is granted the 'Query Limit'
explicitly, other groups users would be deprived the default value and
run into 'query disabled' error when they try to open any changes
dashboard UI.
This issue can be fixed by granting default value(+0..500) of 'Query Limit'
to Anonymous Users, but this is inconvenient, and in most cases Admin
do not know the root reason of 'query disabled' error.
Fixed by always keeping the default capability valid.
Change-Id: Ia4c7120df85d519fd5fc7f00a29ab405f959ff5a
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/CapabilityControl.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/CapabilityControl.java
index 193ea04..01e8002 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/account/CapabilityControl.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/CapabilityControl.java
@@ -230,9 +230,18 @@
List<PermissionRule> ruleList) {
int min = 0;
int max = 0;
- for (PermissionRule rule : ruleList) {
- min = Math.min(min, rule.getMin());
- max = Math.max(max, rule.getMax());
+ if (ruleList.isEmpty()) {
+ PermissionRange.WithDefaults defaultRange =
+ GlobalCapability.getRange(permissionName);
+ if (defaultRange != null) {
+ min = defaultRange.getDefaultMin();
+ max = defaultRange.getDefaultMax();
+ }
+ } else {
+ for (PermissionRule rule : ruleList) {
+ min = Math.min(min, rule.getMin());
+ max = Math.max(max, rule.getMax());
+ }
}
return new PermissionRange(permissionName, min, max);
}