]> source.dussan.org Git - sonarqube.git/commitdiff
Fix bug in AuthorizationDao#keepAuthorizedProjectIds()
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 10 May 2017 18:47:56 +0000 (20:47 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 10 May 2017 21:08:31 +0000 (23:08 +0200)
Input of ids is not correctly partitioned. The SQL request may fail
on some databases (Oracle at least) if the input list of ids
is greater than 1'000 elements.

server/sonar-db-dao/src/main/java/org/sonar/db/permission/AuthorizationDao.java

index d55f13ce0e7769b2d74f0b41a634a83d201389ea..06eda85127486168eab0a9c5eb43bf6c59db3bf1 100644 (file)
@@ -124,14 +124,14 @@ public class AuthorizationDao implements Dao {
     return mapper(dbSession).selectOrganizationUuidsOfUserWithGlobalPermission(userId, permission);
   }
 
-  public Set<Long> keepAuthorizedProjectIds(DbSession dbSession, Collection<Long> componentIds, @Nullable Integer userId, String role) {
+  public Set<Long> keepAuthorizedProjectIds(DbSession dbSession, Collection<Long> componentIds, @Nullable Integer userId, String permission) {
     return executeLargeInputsIntoSet(
       componentIds,
       partition -> {
         if (userId == null) {
-          return mapper(dbSession).keepAuthorizedProjectIdsForAnonymous(role, componentIds);
+          return mapper(dbSession).keepAuthorizedProjectIdsForAnonymous(permission, partition);
         }
-        return mapper(dbSession).keepAuthorizedProjectIdsForUser(userId, role, componentIds);
+        return mapper(dbSession).keepAuthorizedProjectIdsForUser(userId, permission, partition);
       });
   }