Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate .RenderString regression #9383

Closed
bep opened this issue Jan 14, 2022 · 3 comments · Fixed by #9398
Closed

Investigate .RenderString regression #9383

bep opened this issue Jan 14, 2022 · 3 comments · Fixed by #9398

Comments

@bep
Copy link
Member

bep commented Jan 14, 2022

See https://discourse.gohugo.io/t/multilingual-related-page-renderstring-regression-in-0-92/36555/16?u=bep

I'm pretty sure this came from #9342 -- but I'm also pretty sure that that PR surfaced an already existing bug re output formats and .Translations, so I think we need to understand and fix the real issue rather than reverting the above.

@ptgott

@bep bep added the Bug label Jan 14, 2022
@bep bep added this to the v0.92.1 milestone Jan 14, 2022
@ptgott
Copy link
Contributor

ptgott commented Jan 14, 2022

Thanks for the heads up. I’ll have time to look into this over the weekend and possibly today.

@danielfdickinson
Copy link

FYI I discovered this issue (with @jmooring's help) through another route:

Quoting Joe:

TLDR: Invoking .Page.RenderString on a page without a backing file throws an erroneous warning

The full discussion is in https://discourse.gohugo.io/t/0-92-new-warning-when-section-has-no-index/36590

ptgott added a commit to ptgott/hugo that referenced this issue Jan 16, 2022
PR gohugoio#9342 introduced a regression in which calling .Translations in a
template and calling RenderString on a translated Page caused a nil
pointer dereference. The issue was that not all Pages returned from
.Translations had initialized ContentProviders at the time the calling
template was being executed.

While PR gohugoio#9342 had attempted to ensure that all ContentProviders were
initialized for translations at build time, it only performed the
initialization for receivers of ContentProvider methods such as
.Summary. However, the ContentProvider's *pageState.pageOutput.cp would
remain uninitialized, causing the nil pointer dereference.

This change edits the .Translations and .AllTranslations methods to
ensure that all of a page's translations have an initialized
content provider in time for a template to be executed.

Since LazyContentProvider is no longer needed with this approach, this
change also reverts the following commits:

- cdcd15b
- 25d645f

Fixes gohugoio#9383
ptgott added a commit to ptgott/hugo that referenced this issue Jan 16, 2022
PR gohugoio#9342 introduced a regression in which calling .Translations in a
template and calling RenderString on a translated Page caused a nil
pointer dereference. The issue was that some Pages returned from
.Translations had a nil cp field at the time the calling template was
being executed.

While PR gohugoio#9342 had attempted to ensure that all ContentProviders were
initialized for translations at build time, it only performed the
initialization for receivers of ContentProvider methods such as
.Summary. However, the ContentProvider's *pageState.pageOutput.cp would
remain uninitialized, causing the nil pointer dereference.

This change edits the .Translations and .AllTranslations methods to
ensure that all of a page's translations have an initialized
content provider in time for a template to be executed.

Since LazyContentProvider is no longer needed with this approach, this
change also reverts the following commits:

- cdcd15b
- 25d645f

Fixes gohugoio#9383
ptgott added a commit to ptgott/hugo that referenced this issue Jan 18, 2022
PR gohugoio#9342 introduced a regression in which calling .Translations in a
template and calling RenderString on a translated Page caused a nil
pointer dereference. The issue was that some Pages returned from
.Translations had a nil cp field at the time the calling template was
being executed.

While PR gohugoio#9342 had attempted to ensure that all ContentProviders were
initialized for translations at build time, it only performed the
initialization for receivers of ContentProvider methods such as
.Summary. However, the ContentProvider's *pageState.pageOutput.cp would
remain uninitialized, causing the nil pointer dereference.

This change edits the .Translations and .AllTranslations methods to
ensure that all of a page's translations have an initialized
content provider in time for a template to be executed.

Since LazyContentProvider is no longer needed with this approach, this
change also reverts the following commits:

- cdcd15b
- 25d645f

Fixes gohugoio#9383
bep pushed a commit to ptgott/hugo that referenced this issue Jan 27, 2022
bep added a commit to ptgott/hugo that referenced this issue Jan 27, 2022
bep added a commit to ptgott/hugo that referenced this issue Jan 27, 2022
@bep bep closed this as completed in #9398 Jan 27, 2022
bep pushed a commit that referenced this issue Jan 27, 2022
bep added a commit that referenced this issue Jan 27, 2022
@github-actions
Copy link

github-actions bot commented Feb 4, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants