mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-11 18:14:15 +01:00
dd8d3f5ebe
When a logged in user with no repositories visits their dashboard, it will
display a search box that lists their own repositories.
This is served by the `repo.SearchRepos` handler, which in turn calls
`commitstatus_service.FindReposLastestCommitStatuses()` with an empty
repo list.
That, in turn, will call `git_model.FindBranchesByRepoAndBranchName()`,
with an empty map. With no map, `FindBranchesByRepoAndBranchName()` ends
up querying the entire `branch` table, because no conditions were set
up.
Armed with a gazillion repo & commit shas, we return to
`FindReposLastestCommitStatuses`, and promptly call
`git_model.GetLatestCommitStatusForPairs`, which constructs a monstrous
query with so many placeholders that the database tells us to go
somewhere else, and flips us off. At least on instances the size of
Codeberg. On smaller instances, it will eventually return, and throw
away all the data, and return an empty set, having performed all this
for naught.
We fix this by short-circuiting `FindBranchesByRepoAndBranchName`, and
returning fast if our inputs are empty.
A test case is included.
Fixes #3521.
Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit
|
||
---|---|---|
.. | ||
TestIterateRepositoryIDsWithLFSMetaObjects | ||
branch.go | ||
branch_list.go | ||
branch_test.go | ||
commit_status.go | ||
commit_status_test.go | ||
lfs.go | ||
lfs_lock.go | ||
lfs_test.go | ||
main_test.go | ||
protected_banch_list_test.go | ||
protected_branch.go | ||
protected_branch_list.go | ||
protected_branch_test.go | ||
protected_tag.go | ||
protected_tag_test.go |