-
Notifications
You must be signed in to change notification settings - Fork 89
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
Archive pages limit uncovers interesting breakage #693
Labels
Milestone
Comments
th-h
added
bugs
discuss
backport needed
Fix that has to be backported to older release branches.
labels
Apr 11, 2020
th-h
added a commit
to th-h/Serendipity
that referenced
this issue
Apr 11, 2020
Since merging s9y#665 `serendipity_plugin_history` breaks with a SQL error message on every archive page but the first one; see s9y#693 for reason and context. Unset `$serendipity['GET']['page']` before calling `serendipity_fetchEntries(`)` (and reset afterwards) to fix that. That's the correct way, I think, as `serendipity_fetchEntries()` is not called in page context here. Signed-off-by: Thomas Hochstein <thh@inter.net>
th-h
added a commit
to th-h/Serendipity
that referenced
this issue
Apr 11, 2020
Since merging s9y#665 `serendipity_plugin_history` breaks with a SQL error message on every archive page but the first one; see s9y#693 for reason and context. Unset `$serendipity['GET']['page']` before calling `serendipity_fetchEntries(`)` (and reset afterwards) to fix that. That's the correct way, I think, as `serendipity_fetchEntries()` is not called in page context here. Signed-off-by: Thomas Hochstein <thh@inter.net>
th-h
added a commit
to th-h/Serendipity
that referenced
this issue
Apr 11, 2020
See s9y#693 for context. That should at least avoid SQL errors. Signed-off-by: Thomas Hochstein <thh@inter.net>
th-h
added a commit
to th-h/Serendipity
that referenced
this issue
Apr 11, 2020
Since merging s9y#665 `serendipity_plugin_history` breaks with a SQL error message on every archive page but the first one; see s9y#693 for reason and context. Unset `$serendipity['GET']['page']` before calling `serendipity_fetchEntries()` (and reset afterwards) to fix that. That's the correct way, I think, as `serendipity_fetchEntries()` is not called in page context here. Add a note to serendipity_fetchEntries() about the problem with page context. Also don't fallback to last page if $totalPages < 1 in serendipity_fetchEntries() That should at least avoid SQL errors. Signed-off-by: Thomas Hochstein <thh@inter.net>
th-h
added a commit
to th-h/Serendipity
that referenced
this issue
Apr 20, 2020
Since merging s9y#665 `serendipity_plugin_history` breaks with a SQL error message on every archive page but the first one; see s9y#693 for reason and context. Unset `$serendipity['GET']['page']` before calling `serendipity_fetchEntries()` (and reset afterwards) to fix that. That's the correct way, I think, as `serendipity_fetchEntries()` is not called in page context here. Add a note to serendipity_fetchEntries() about the problem with page context. Also don't fallback to last page if $totalPages < 1 in serendipity_fetchEntries() That should at least avoid SQL errors. Signed-off-by: Thomas Hochstein <thh@inter.net>
th-h
added a commit
to th-h/Serendipity
that referenced
this issue
Apr 20, 2020
Since merging s9y#665 `serendipity_plugin_history` breaks with a SQL error message on every archive page but the first one; see s9y#693 for reason and context. Unset `$serendipity['GET']['page']` before calling `serendipity_fetchEntries()` (and reset afterwards) to fix that. That's the correct way, I think, as `serendipity_fetchEntries()` is not called in page context here. Add a note to serendipity_fetchEntries() about the problem with page context. Also don't fallback to last page if $totalPages < 1 in serendipity_fetchEntries() That should at least avoid SQL errors. Signed-off-by: Thomas Hochstein <thh@inter.net>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Since merging of #665 - which was backported and released with 2.3.3 -
serendipity_plugin_history
breaks with a SQL error for all archive pages but the first:This is due to the fact that
serendipity_fetchEntries()
ininclude/functions_entries.inc.php
is not just called to display entries on pages, but also to get a list of entries for many other use cases so the calculation of$totalEntries
may not always return the result that you expected. Please bear with me, it's a bit of convoluted.In this case, we're showing archive page 2 of many. On this page,
serendipity_plugin_history
tries to show up to 10 older entries that have been posted about a year ago (let's say at least 360, but not more than 370 days ago). It does that by callingserendipity_fetchEntries()
with a range and a limit of 10. But today, there are no historic entries to show.The code in
serendipity_fetchEntries()
will construct$serendipity['fullCountQuery']
as always with all constraints from theserendipity_fetchEntries()
call and pass it toserendipity_getTotalEntries()
; the result will be0
this time, so$totalEntries
will be0
, too. That means we have zero archive pages ($totalPages
) , too. The archive page limiting code will set$serendipity['GET']['page']
to zero accordingly.And further on, the paginating code kicks in and constructs the
LIMIT
query. It does that by setting the offset to the number of entries that have already been displayed by subtracting1
from the current page and multiplying that with the limit of entries to show, i.e. on page 2 when showing 10 entries on every page, it gives(2-1)*10 = 10
. But we have forced$serendipity['GET']['page']
to zero, so now it is(0-1)*10 = -10
which is invalid.We could roll back that change, but I think we don't consider the possibility that we don't use
$limit
to paginate here, i.e. thatserendipity_fetchEntries()
is called for another purpose than displaying an archive page, at all. It would also be wrong to display the "historic" entries in reverse order if$serendipity['archiveSortStable'])
ist set to true.So I think the archive limiting code is not wrong per se but has uncovered a design problem. That's why I think we should keep that code to uncover other problems like this.
We could add another parameter to
serendipity_fetchEntries()
to check if we need to paginate, but the parameter list already is impressingly long. So I'll fix the problem in the calling code; we'll have to keep that in mind for other places where that will creep up, so I'll let this issue open a bit for discussion.The text was updated successfully, but these errors were encountered: