From b5194624e021360ccdec20cb58bba57c23028c3f Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 3 Jul 2023 18:18:13 +0200 Subject: [PATCH] fix: don't try to load subscriptions for nonexistent projects --- pkg/models/subscription.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/models/subscription.go b/pkg/models/subscription.go index 67a84d929d4..00322ad9f76 100644 --- a/pkg/models/subscription.go +++ b/pkg/models/subscription.go @@ -262,6 +262,9 @@ func getSubscriptionsForProjects(s *xorm.Session, projectIDs []int64, u *user.Us var ps = make(map[int64]*Project) for _, eID := range projectIDs { + if eID < 1 { + continue + } ps[eID], err = GetProjectSimpleByID(s, eID) if err != nil { return nil, err @@ -309,7 +312,8 @@ func getSubscriptionsForProjects(s *xorm.Session, projectIDs []int64, u *user.Us // If the current project does not have a subscription, climb up the tree until a project has one, // then use that subscription for all child projects _, has := projectsToSubscriptions[eID] - if !has { + _, hasProject := ps[eID] + if !has && hasProject { var parent = ps[eID].ParentProject for parent != nil { sub, has := projectsToSubscriptions[parent.ID]