1
0

fix: cycles in tasks array when memory caching was enabled

Resolves #1119
This commit is contained in:
kolaente
2022-07-07 18:34:49 +02:00
parent 230478aae9
commit f5a4c136fb
3 changed files with 11 additions and 1 deletions

View File

@ -17,6 +17,7 @@
package models
import (
"github.com/jinzhu/copier"
"math"
"regexp"
"sort"
@ -676,7 +677,13 @@ func addRelatedTasksToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]
continue
}
fullRelatedTasks[rt.OtherTaskID].IsFavorite = taskFavorites[rt.OtherTaskID]
taskMap[rt.TaskID].RelatedTasks[rt.RelationKind] = append(taskMap[rt.TaskID].RelatedTasks[rt.RelationKind], fullRelatedTasks[rt.OtherTaskID])
// We're duplicating the other task to avoid cycles as these can't be represented properly in json
// and would thus fail with an error.
otherTask := &Task{}
copier.Copy(otherTask, fullRelatedTasks[rt.OtherTaskID])
otherTask.RelatedTasks = nil
taskMap[rt.TaskID].RelatedTasks[rt.RelationKind] = append(taskMap[rt.TaskID].RelatedTasks[rt.RelationKind], otherTask)
}
return