navigation: Cache and copy Menu for sorting
authorsatotake <doublequotation@gmail.com>
Sun, 23 May 2021 08:42:01 +0000 (17:42 +0900)
committerGitHub <noreply@github.com>
Sun, 23 May 2021 08:42:01 +0000 (10:42 +0200)
commit785a31b5b84643f4769f9bd363599cbcce86f098
tree06faf195e70dab43a035235173bc173aa5567735
parentbc1e05286a96d08ad02ad200d6a4076bb01c486e
navigation: Cache and copy Menu for sorting

.Site.Menus is mutated when it is sorted for now and this causes concurrency problem (#7594)
In this patch, each related sort function copies Menu before sorting to prevent
race condition.

Pages already have such a sort and cache logic and this patch is identical to it.

Closes #7594
hugolib/menu_test.go
navigation/menu.go
navigation/menu_cache.go [new file with mode: 0644]
navigation/menu_cache_test.go [new file with mode: 0644]