Skip to content

Commit

Permalink
hugolib: Reset the global pages cache on server rebuilds
Browse files Browse the repository at this point in the history
In Hugo 0.42, this could lead to errors of type `runtime error: invalid memory address or nil pointer dereference` in some rare situations.

Note that this was also an issue before 0.42, but the symptom was then potentially stale list content on rebuilds on content changes.

This commit also improves the above error message.

Fixes #4845
  • Loading branch information
bep committed Jun 13, 2018
1 parent 34ee27a commit 128f14e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hugolib/page_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ func (p *PageOutput) Render(layout ...string) template.HTML {
}

func (p *Page) Render(layout ...string) template.HTML {
if p.mainPageOutput == nil {
panic(fmt.Sprintf("programming error: no mainPageOutput for %q", p.Path()))
}
return p.mainPageOutput.Render(layout...)
}

Expand Down
2 changes: 2 additions & 0 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,8 @@ func (s *Site) resetBuildState() {

s.expiredCount = 0

spc = newPageCache()

for _, p := range s.rawAllPages {
p.subSections = Pages{}
p.parent = nil
Expand Down

0 comments on commit 128f14e

Please sign in to comment.