diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-06-23 23:22:43 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-06-23 18:22:43 +0300 |
commit | aa7c34cf86081b71f796f6e5da60e62a3cda43ce (patch) | |
tree | c9e4b4f1490b43e942fa71b37748072d3fe441e8 /models | |
parent | baefea311f1a66a97f9a2779ad3342f4f8167d28 (diff) | |
download | gitea-aa7c34cf86081b71f796f6e5da60e62a3cda43ce.tar.gz gitea-aa7c34cf86081b71f796f6e5da60e62a3cda43ce.zip |
Fix error log when loading issues caused by a xorm bug (#7271)
* fix error log when loading issues caused by a xorm bug
* upgrade packages
* fix fmt
* fix Consistency
* fix tests
Diffstat (limited to 'models')
-rw-r--r-- | models/action.go | 2 | ||||
-rw-r--r-- | models/consistency.go | 2 | ||||
-rw-r--r-- | models/issue.go | 3 | ||||
-rw-r--r-- | models/issue_comment.go | 2 | ||||
-rw-r--r-- | models/issue_list.go | 76 | ||||
-rw-r--r-- | models/issue_reaction.go | 2 | ||||
-rw-r--r-- | models/issue_tracked_time.go | 2 | ||||
-rw-r--r-- | models/log.go | 2 | ||||
-rw-r--r-- | models/login_source.go | 2 | ||||
-rw-r--r-- | models/migrations/v31.go | 2 | ||||
-rw-r--r-- | models/migrations/v38.go | 2 | ||||
-rw-r--r-- | models/migrations/v75.go | 2 | ||||
-rw-r--r-- | models/migrations/v78.go | 2 | ||||
-rw-r--r-- | models/migrations/v85.go | 2 | ||||
-rw-r--r-- | models/models.go | 2 | ||||
-rw-r--r-- | models/org.go | 2 | ||||
-rw-r--r-- | models/release.go | 2 | ||||
-rw-r--r-- | models/repo.go | 2 | ||||
-rw-r--r-- | models/repo_list.go | 2 | ||||
-rw-r--r-- | models/repo_unit.go | 2 | ||||
-rw-r--r-- | models/review.go | 4 | ||||
-rw-r--r-- | models/ssh_key.go | 2 | ||||
-rw-r--r-- | models/topic.go | 2 | ||||
-rw-r--r-- | models/unit_tests.go | 2 | ||||
-rw-r--r-- | models/user.go | 4 |
25 files changed, 53 insertions, 76 deletions
diff --git a/models/action.go b/models/action.go index ee5d052509..89283930e9 100644 --- a/models/action.go +++ b/models/action.go @@ -24,7 +24,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/Unknwon/com" - "github.com/go-xorm/builder" + "xorm.io/builder" ) // ActionType represents the type of an action. diff --git a/models/consistency.go b/models/consistency.go index 0c279eaaf8..f9fa3028fd 100644 --- a/models/consistency.go +++ b/models/consistency.go @@ -39,7 +39,7 @@ func CheckConsistencyFor(t *testing.T, beansToCheck ...interface{}) { ptrToSliceValue := reflect.New(sliceType) ptrToSliceValue.Elem().Set(sliceValue) - assert.NoError(t, x.Where(bean).Find(ptrToSliceValue.Interface())) + assert.NoError(t, x.Table(bean).Find(ptrToSliceValue.Interface())) sliceValue = ptrToSliceValue.Elem() for i := 0; i < sliceValue.Len(); i++ { diff --git a/models/issue.go b/models/issue.go index 27298b8a86..b5504beb71 100644 --- a/models/issue.go +++ b/models/issue.go @@ -19,8 +19,8 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/Unknwon/com" - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" + "xorm.io/builder" ) // Issue represents an issue or pull request of repository. @@ -1428,6 +1428,7 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { if err := sess.Find(&issues); err != nil { return nil, fmt.Errorf("Find: %v", err) } + sess.Close() if err := IssueList(issues).LoadAttributes(); err != nil { return nil, fmt.Errorf("LoadAttributes: %v", err) diff --git a/models/issue_comment.go b/models/issue_comment.go index d75d9d7db1..c9f1bd9d5f 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -15,8 +15,8 @@ import ( "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" "github.com/Unknwon/com" - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" + "xorm.io/builder" api "code.gitea.io/gitea/modules/structs" diff --git a/models/issue_list.go b/models/issue_list.go index 4ddb32da13..e3516b55b9 100644 --- a/models/issue_list.go +++ b/models/issue_list.go @@ -7,9 +7,7 @@ package models import ( "fmt" - "code.gitea.io/gitea/modules/log" - - "github.com/go-xorm/builder" + "xorm.io/builder" ) // IssueList defines a list of issues @@ -148,19 +146,17 @@ func (issues IssueList) loadLabels(e Engine) error { var labelIssue LabelIssue err = rows.Scan(&labelIssue) if err != nil { - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadLabels: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadLabels: Close: %v", err1) } return err } issueLabels[labelIssue.IssueLabel.IssueID] = append(issueLabels[labelIssue.IssueLabel.IssueID], labelIssue.Label) } - // When there are no rows left and we try to close it, xorm will complain with an error. + // When there are no rows left and we try to close it. // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadLabels: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadLabels: Close: %v", err1) } left -= limit issueIDs = issueIDs[limit:] @@ -241,20 +237,16 @@ func (issues IssueList) loadAssignees(e Engine) error { var assigneeIssue AssigneeIssue err = rows.Scan(&assigneeIssue) if err != nil { - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadAssignees: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadAssignees: Close: %v", err1) } return err } assignees[assigneeIssue.IssueAssignee.IssueID] = append(assignees[assigneeIssue.IssueAssignee.IssueID], assigneeIssue.Assignee) } - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadAssignees: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadAssignees: Close: %v", err1) } left -= limit issueIDs = issueIDs[limit:] @@ -300,19 +292,15 @@ func (issues IssueList) loadPullRequests(e Engine) error { var pr PullRequest err = rows.Scan(&pr) if err != nil { - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadPullRequests: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadPullRequests: Close: %v", err1) } return err } pullRequestMaps[pr.IssueID] = &pr } - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadPullRequests: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadPullRequests: Close: %v", err1) } left -= limit issuesIDs = issuesIDs[limit:] @@ -349,19 +337,15 @@ func (issues IssueList) loadAttachments(e Engine) (err error) { var attachment Attachment err = rows.Scan(&attachment) if err != nil { - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadAttachments: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadAttachments: Close: %v", err1) } return err } attachments[attachment.IssueID] = append(attachments[attachment.IssueID], &attachment) } - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadAttachments: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadAttachments: Close: %v", err1) } left -= limit issuesIDs = issuesIDs[limit:] @@ -399,19 +383,15 @@ func (issues IssueList) loadComments(e Engine, cond builder.Cond) (err error) { var comment Comment err = rows.Scan(&comment) if err != nil { - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadComments: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadComments: Close: %v", err1) } return err } comments[comment.IssueID] = append(comments[comment.IssueID], &comment) } - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadComments: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadComments: Close: %v", err1) } left -= limit issuesIDs = issuesIDs[limit:] @@ -461,19 +441,15 @@ func (issues IssueList) loadTotalTrackedTimes(e Engine) (err error) { var totalTime totalTimesByIssue err = rows.Scan(&totalTime) if err != nil { - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadTotalTrackedTimes: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %v", err1) } return err } trackedTimes[totalTime.IssueID] = totalTime.Time } - // When there are no rows left and we try to close it, xorm will complain with an error. - // Since that is not relevant for us, we can safely ignore it. - if err := rows.Close(); err != nil { - log.Error("IssueList.loadTotalTrackedTimes: Close: %v", err) + if err1 := rows.Close(); err1 != nil { + return fmt.Errorf("IssueList.loadTotalTrackedTimes: Close: %v", err1) } left -= limit ids = ids[limit:] diff --git a/models/issue_reaction.go b/models/issue_reaction.go index 8f3ee7bfe2..e0df6f757b 100644 --- a/models/issue_reaction.go +++ b/models/issue_reaction.go @@ -11,8 +11,8 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" + "xorm.io/builder" ) // Reaction represents a reactions on issues and comments. diff --git a/models/issue_tracked_time.go b/models/issue_tracked_time.go index 56ba525776..5482a45f2a 100644 --- a/models/issue_tracked_time.go +++ b/models/issue_tracked_time.go @@ -10,8 +10,8 @@ import ( "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" + "xorm.io/builder" ) // TrackedTime represents a time that was spent for a specific issue. diff --git a/models/log.go b/models/log.go index 38d6caf07c..4caea9a8b7 100644 --- a/models/log.go +++ b/models/log.go @@ -9,7 +9,7 @@ import ( "code.gitea.io/gitea/modules/log" - "github.com/go-xorm/core" + "xorm.io/core" ) // XORMLogBridge a logger bridge from Logger to xorm diff --git a/models/login_source.go b/models/login_source.go index 8eefec4ae5..626c232772 100644 --- a/models/login_source.go +++ b/models/login_source.go @@ -15,8 +15,8 @@ import ( "strings" "github.com/Unknwon/com" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/core" "code.gitea.io/gitea/modules/auth/ldap" "code.gitea.io/gitea/modules/auth/oauth2" diff --git a/models/migrations/v31.go b/models/migrations/v31.go index b7ceecfc38..d6cea4c51b 100644 --- a/models/migrations/v31.go +++ b/models/migrations/v31.go @@ -8,8 +8,8 @@ import ( "fmt" "time" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/core" ) func addLoginSourceSyncEnabledColumn(x *xorm.Engine) error { diff --git a/models/migrations/v38.go b/models/migrations/v38.go index eb90f9fbff..6060b70fe8 100644 --- a/models/migrations/v38.go +++ b/models/migrations/v38.go @@ -9,8 +9,8 @@ import ( "code.gitea.io/gitea/models" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/core" ) func removeCommitsUnitType(x *xorm.Engine) (err error) { diff --git a/models/migrations/v75.go b/models/migrations/v75.go index 62f92b77db..58d1d34c98 100644 --- a/models/migrations/v75.go +++ b/models/migrations/v75.go @@ -5,8 +5,8 @@ package migrations import ( - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" + "xorm.io/builder" ) func clearNonusedData(x *xorm.Engine) error { diff --git a/models/migrations/v78.go b/models/migrations/v78.go index 310c479d01..511a4f57fa 100644 --- a/models/migrations/v78.go +++ b/models/migrations/v78.go @@ -10,8 +10,8 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/log" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/core" ) func renameRepoIsBareToIsEmpty(x *xorm.Engine) error { diff --git a/models/migrations/v85.go b/models/migrations/v85.go index d511628b8d..b8d0ee5443 100644 --- a/models/migrations/v85.go +++ b/models/migrations/v85.go @@ -7,8 +7,8 @@ package migrations import ( "fmt" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/core" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/generate" diff --git a/models/models.go b/models/models.go index 5752a8edd6..3b3d8ec30a 100644 --- a/models/models.go +++ b/models/models.go @@ -20,8 +20,8 @@ import ( // Needed for the MySQL driver _ "github.com/go-sql-driver/mysql" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/core" // Needed for the Postgresql driver _ "github.com/lib/pq" diff --git a/models/org.go b/models/org.go index 65002eadff..d86109de57 100644 --- a/models/org.go +++ b/models/org.go @@ -15,8 +15,8 @@ import ( "code.gitea.io/gitea/modules/structs" "github.com/Unknwon/com" - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" + "xorm.io/builder" ) var ( diff --git a/models/release.go b/models/release.go index 28a2891013..036b5f78b9 100644 --- a/models/release.go +++ b/models/release.go @@ -16,7 +16,7 @@ import ( api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - "github.com/go-xorm/builder" + "xorm.io/builder" ) // Release represents a release of repository. diff --git a/models/repo.go b/models/repo.go index 215222e279..2f732d0e26 100644 --- a/models/repo.go +++ b/models/repo.go @@ -37,9 +37,9 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/Unknwon/com" - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" ini "gopkg.in/ini.v1" + "xorm.io/builder" ) var repoWorkingPool = sync.NewExclusivePool() diff --git a/models/repo_list.go b/models/repo_list.go index 5655404f7c..7460c4b0ed 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - "github.com/go-xorm/builder" + "xorm.io/builder" ) // RepositoryListDefaultPageSize is the default number of repositories diff --git a/models/repo_unit.go b/models/repo_unit.go index 430f5a242f..80126270de 100644 --- a/models/repo_unit.go +++ b/models/repo_unit.go @@ -10,8 +10,8 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/Unknwon/com" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/core" ) // RepoUnit describes all units of a repository diff --git a/models/review.go b/models/review.go index 5f856fbd89..458d58152e 100644 --- a/models/review.go +++ b/models/review.go @@ -11,9 +11,9 @@ import ( api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - "github.com/go-xorm/builder" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" + "xorm.io/builder" + "xorm.io/core" ) // ReviewType defines the sort of feedback a review gives diff --git a/models/ssh_key.go b/models/ssh_key.go index 15a10826d8..ceb4d97560 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -25,9 +25,9 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/Unknwon/com" - "github.com/go-xorm/builder" "github.com/go-xorm/xorm" "golang.org/x/crypto/ssh" + "xorm.io/builder" ) const ( diff --git a/models/topic.go b/models/topic.go index da1815be76..666196ba8e 100644 --- a/models/topic.go +++ b/models/topic.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/modules/util" - "github.com/go-xorm/builder" + "xorm.io/builder" ) func init() { diff --git a/models/unit_tests.go b/models/unit_tests.go index 19fc95ea65..330dc5ee4e 100644 --- a/models/unit_tests.go +++ b/models/unit_tests.go @@ -18,10 +18,10 @@ import ( "code.gitea.io/gitea/modules/setting" "github.com/Unknwon/com" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" "github.com/stretchr/testify/assert" "gopkg.in/testfixtures.v2" + "xorm.io/core" ) // NonexistentID an ID that will never exist diff --git a/models/user.go b/models/user.go index 4dc9aec650..aa392b1ea9 100644 --- a/models/user.go +++ b/models/user.go @@ -32,11 +32,11 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/Unknwon/com" - "github.com/go-xorm/builder" - "github.com/go-xorm/core" "github.com/go-xorm/xorm" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/ssh" + "xorm.io/builder" + "xorm.io/core" ) // UserType defines the user type |