From 1b59e6f91011cdeccf146a20f758677143710885 Mon Sep 17 00:00:00 2001 From: Flare Date: Tue, 20 Sep 2016 17:54:47 +0800 Subject: [PATCH 1/3] Fix 500 error caused by deleted users on issues (#3675) --- models/issue.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/models/issue.go b/models/issue.go index 208204b0767..3c1e27d7370 100644 --- a/models/issue.go +++ b/models/issue.go @@ -94,13 +94,8 @@ func (issue *Issue) loadAttributes(e Engine) (err error) { if issue.Poster == nil { issue.Poster, err = getUserByID(e, issue.PosterID) if err != nil { - if IsErrUserNotExist(err) { - issue.PosterID = -1 - issue.Poster = NewGhostUser() - } else { - return fmt.Errorf("getUserByID.(poster) [%d]: %v", issue.PosterID, err) - } - return + issue.PosterID = -1 + issue.Poster = NewGhostUser() } } From fd6be0d17e8174a20e5c9cc49219f0612995cce3 Mon Sep 17 00:00:00 2001 From: Flare Date: Sat, 5 Nov 2016 02:47:54 +0800 Subject: [PATCH 2/3] Still print error if user does not exist --- models/issue.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/issue.go b/models/issue.go index 3c1e27d7370..569d8aa9409 100644 --- a/models/issue.go +++ b/models/issue.go @@ -96,6 +96,10 @@ func (issue *Issue) loadAttributes(e Engine) (err error) { if err != nil { issue.PosterID = -1 issue.Poster = NewGhostUser() + if !IsErrUserNotExist(err) { + return fmt.Errorf("getUserByID.(poster) [%d]: %v", issue.PosterID, err) + } + return } } From a6c487f6caa93c3b661ecc345b2f95c206718316 Mon Sep 17 00:00:00 2001 From: Flare Date: Wed, 9 Nov 2016 13:07:01 +0800 Subject: [PATCH 3/3] Fix err not being nil --- models/issue.go | 1 + 1 file changed, 1 insertion(+) diff --git a/models/issue.go b/models/issue.go index 569d8aa9409..6ef5ae6218b 100644 --- a/models/issue.go +++ b/models/issue.go @@ -99,6 +99,7 @@ func (issue *Issue) loadAttributes(e Engine) (err error) { if !IsErrUserNotExist(err) { return fmt.Errorf("getUserByID.(poster) [%d]: %v", issue.PosterID, err) } + err = nil return } }