ChangeQueryBuilder: Always get user lazily from Arguments
There were a few special predicates that depended on constructing new ChangeQueryBuilders with the same arguments but a different user. This created the error-prone situation of the code in these predicates having two different users available (from the args and passed in explicitly), where only one of them was the right user to be using. Teach these predicates to get the user they need directly from the Arguments, and change callers to construct new Arguments containing the appropriate user. Also add some new methods to Arguments to extract a CurrentUser and/or IdentifiedUser, throwing QueryParseException with a useful message if the user is not logged in. This allows queries that do not depend on the current user to succeed as in contexts without a user, e.g. searching for submitted changes in a background thread. Change-Id: Ic6479455b0978306ccd3239b0cc35c7253f04854
This commit is contained in:
@@ -27,8 +27,7 @@ public class FakeQueryBuilder extends ChangeQueryBuilder {
|
||||
FakeQueryBuilder.class),
|
||||
new ChangeQueryBuilder.Arguments(null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null, indexes,
|
||||
null, null, null, null),
|
||||
null);
|
||||
null, null, null, null));
|
||||
}
|
||||
|
||||
@Operator
|
||||
|
Reference in New Issue
Block a user