diff --git a/include/functions_entries.inc.php b/include/functions_entries.inc.php index a1e315ef..b88e73d7 100644 --- a/include/functions_entries.inc.php +++ b/include/functions_entries.inc.php @@ -406,6 +406,19 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe if (!empty($limit)) { if (isset($serendipity['GET']['page']) && ($serendipity['GET']['page'] > 1 || serendipity_db_bool($serendipity['archiveSortStable'])) && !strstr($limit, ',')) { + + // serendipity_fetchEntries() is mostly called in page context to + // deliver a list of entries to display on archive, search result + // or other pages, where $limit means the number of entries to + // display on each page. This code depends on that notion, + // catches request for non-existing pages and applies + // pagination. + // If you don't work in a page context, e.g. you just want to fetch + // a list of entries to display in a sidebar, you should think + // about saving and unsetting $serendipity['GET']['page'] before + // calling serendipity_fetchEntries() and reset it to the saved + // value afterwards. + // See https://github.com/s9y/Serendipity/issues/693 for context. $totalEntries = serendipity_getTotalEntries(); $totalPages = ceil($totalEntries / $limit);