-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Pagination is broken with "invalid memory or nil pointer dereference" in 0.123.0-DEV #11949
Comments
Thanks for this, much appreciated. I don't think "pagination is broken" is a generally valid statement (we have lots of tests). Do you have an example site that shows this problem? |
@TiGR In which template does your code appear? Or, more specifically, is the pagination code called from a list page (home, section, taxonomy, or term), or from a single page? |
In general, the idea is that we have structure like {{ $places := slice }}
{{ range $events }}
{{/* in this example .place is an item of (site.GetPage "places").Pages list, that is a Page */}}
{{ $places = $places | append .place }}
{{ end }} And then we do the code I've mentioned above: <div class="places">
{{ $paginate := .Paginate $places 10 }}
{{ range $index, $page := $paginate.Pages }}
{{ $page.Render "list_item" }}
{{ end }}
</div>
<div class="pagination__wrap">
{{- template "_internal/pagination.html" . -}}
</div> With that code I get errors on $paginate.Pages and on including pagination template. |
It's a section page. But it's a tricky one, it's an empty sub-section with no pages inside (like |
I am unable to reproduce the problem with this test site:
The only way I can reproduce the error (or something close to it) is to place the code (or call to the containing partial) in a single page template, which is not allowed. You can only paginate from list templates (home, section, taxonomy, or term). When called from a single page template, the "invalid memory address or nil pointer dereference" error has been thrown since v0.54.1. Prior to that the error message was "error calling Paginate: Paginators not supported for pages of type "page". See #11953. Your template code is in |
Please rebuild hugo from HEAD (6c3b6ba or later) and test again to see if the error message changes. |
Well. That's weird. The message has indeed changed. Now I get:
But the problem is, the page we're talking about is supposed to be a section according to the documentation, and everything worked fine on previous versions. I have the following structure:
And the only place were I have this template rendered is in Also, moving events directory to content top level fixes the issue, but I need it where it is now and I can't get it why it is not considered a section. |
Also, it might be important, we have a bunch of |
@TiGR the devil is in the detail here, I guess, which is not possible for me to determine without seeing the full source. But one of the improvements in this next version is a simplified logic in this area, to prepare for other content sources than files. So, the logic around handling of duplicates may have changed. So, if you have something ala:
Then that may explain it, but again, it's hard for me to guess without seeing the source. That said, I appreciate your bug reports about this. I'm confident that we needed to make these changes, but I also understood that it could create some breakage in the wild. What I can do is to add some more details to the message so you can see what backing file is being used in the "non section". |
Can you try this with my latest commit in 1891d5e |
Well, that seems to be definitely related with #11958, as I get the following:
Let me try building the entire website (this might take some time) |
Well, the entire website (without disabled languages) builds well. |
I'm closing this, as this certainly is "another issue". |
I can reproduce the behavior if I erroneously add |
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. |
I get error like this:
And somewhat related issue is error like this:
in code like this:
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
No, the latest stable release works well
The text was updated successfully, but these errors were encountered: