forked from forgejo/forgejo
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
This commit is contained in:
parent
baefea311f
commit
aa7c34cf86
156 changed files with 1854 additions and 1833 deletions
|
@ -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.
|
||||
|
|
|
@ -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++ {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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:]
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"github.com/go-xorm/builder"
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue