@@ -285,7 +285,9 @@ func Issues(ctx *context.Context) {
285
285
}
286
286
opts .LabelIDs = labelIDs
287
287
288
- opts .RepoIDs = repoIDs
288
+ if len (repoIDs ) > 0 {
289
+ opts .RepoIDs = repoIDs
290
+ }
289
291
290
292
issues , err := models .Issues (opts )
291
293
if err != nil {
@@ -295,23 +297,29 @@ func Issues(ctx *context.Context) {
295
297
296
298
showReposMap := make (map [int64 ]* models.Repository , len (counts ))
297
299
for repoID := range counts {
298
- showReposMap [repoID ], err = models .GetRepositoryByID (repoID )
299
- if models .IsErrRepoNotExist (err ) {
300
- ctx .NotFound ("GetRepositoryByID" , err )
301
- return
302
- } else if err != nil {
303
- ctx .ServerError ("GetRepositoryByID" , fmt .Errorf ("[%d]%v" , repoID , err ))
304
- return
305
- }
300
+ if repoID > 0 {
301
+ if _ , ok := showReposMap [repoID ]; ! ok {
302
+ repo , err := models .GetRepositoryByID (repoID )
303
+ if models .IsErrRepoNotExist (err ) {
304
+ ctx .NotFound ("GetRepositoryByID" , err )
305
+ return
306
+ } else if err != nil {
307
+ ctx .ServerError ("GetRepositoryByID" , fmt .Errorf ("[%d]%v" , repoID , err ))
308
+ return
309
+ }
310
+ showReposMap [repoID ] = repo
311
+ }
312
+ repo := showReposMap [repoID ]
306
313
307
- // Check if user has access to given repository.
308
- perm , err := models .GetUserRepoPermission (showReposMap [repoID ], ctxUser )
309
- if err != nil {
310
- ctx .ServerError ("GetUserRepoPermission" , fmt .Errorf ("[%d]%v" , repoID , err ))
311
- return
312
- }
313
- if ! perm .CanRead (models .UnitTypeIssues ) {
314
- log .Error ("User created Issues in Repository which they no longer have access to: [%d]" , repoID )
314
+ // Check if user has access to given repository.
315
+ perm , err := models .GetUserRepoPermission (repo , ctxUser )
316
+ if err != nil {
317
+ ctx .ServerError ("GetUserRepoPermission" , fmt .Errorf ("[%d]%v" , repoID , err ))
318
+ return
319
+ }
320
+ if ! perm .CanRead (models .UnitTypeIssues ) {
321
+ log .Error ("User created Issues in Repository which they no longer have access to: [%d]" , repoID )
322
+ }
315
323
}
316
324
}
317
325
0 commit comments