When going forward a couple of pages and then going back to page 1 the pager displays Page 0. This could be somehow caused by the fact that the site in question is not in english. I have created translations for the following string:

Page @count => Sida @count
Page 1 => Sida 1

I can't help to think this might also be related to the fact that the $_GET['page'] parameter is missing on the first page.

Views 7.x-3.8
Views Litepager 7.x-3.0

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Peter Törnstrand’s picture

Also, when the pager displays Page 0 the paging function stops working. The next link loses the ?page=1 parameter.

It might also be cache related :-)

Peter Törnstrand’s picture

Issue summary: View changes
Peter Törnstrand’s picture

I have tried using the latest 7.x-3.x-dev release. Same error.

anavarre’s picture

I'm also getting the "Page 0" issue, but without even being able to paginate back and forth from any given views display. It just returns page 0 and reloads the page when you click "next".

What's odd is it doesn't happen on all views display at once. Only a few of them, "randomly" (not likely, but that's the impression it gives).

Only way to fix the issue is to a) clear all caches and b) clear the reverse proxy cache for the page.

Amestar’s picture

Same error in Drupal version 7.28, Views (views) 7.x-3.8, Views Litepager (views_litepager) 7.x-3.0. Works ok until I press the back button of lite pager. Where the page number turns 0 and it's no longer working.

Talkless’s picture

I have same problem with same setup as Amestar. Site is running for quite some time, but I noticed it just recetly. I use Litepager in /frontpage view, using Views Content Cache.

iacono’s picture

Had this issue as well and just fixed it. We had 5 lite pagers on one panel and had views content cache enabled as well. Pagers were displaying Page 0 on the first page and after navigating forward you could not return to the first page. Sometimes the the pager would die completely and stop reloading altogether.

I think the issue has something to do with multiple pagers on one page and the views content cache. Here's what fixed it for me:

Go to your view and check the settings for the litepager. Change the Pager ID setting to a higher number for each litepager in use on the page. View 1 pager ID =5, View 2 Pager ID= 10, View 3 Pager ID =15, etc.

Turn OFF any time or content cache setting that are currently applied to that lite paged view.

That fixed it for us.

heddn’s picture

This is entirely a caching issue. Nothing to do with multiple pagers. Its really a fundamental architectural feature of litepager. Because of how caching operates in views, it stores into cache the $view->results. This is cached BEFORE the pager query() and post_execute() gets run. See views_plugin_query_default->execute().

Since there are 0 results (according to cache), then this really makes returning a pager impossible.

Summary: this module and views caching are mutually exclusive. Can we get that added to the project page so as to help others out?

joshf’s picture

Component: Code » Documentation

Thank you @heddn! I can confirm that disabling Views caching fixed this issue for me.

mattwhelan’s picture

I had this same problem. Fixed it by disabling query caching in my view.

But I'm still curious. I recently upgraded to Views 7.x-3.8, which came out in May. Views Litepager worked fine with query caching enabled before the latest version of Views (7.x-3.8), so I'm guessing a change in the Views module is responsible for this issue? Does anybody know where the problem stems from in the Views code (or the change that causes problems with Views Litepager code)? I'm looking, but the complexity of that module is a bit beyond me.

heddn’s picture

re #10: See #8, specifically views_plugin_query_default->execute().

sheldonkreger’s picture

I'm not entirely convinced this is a documentation issue. Litepager should be able to work smoothly on cached views. I see this as a code issue, am I right?

heddn’s picture

Its not an issue for this pager to resole. It would need to be fixed upstream in views first.

Talkless’s picture

Is there a relevant Views bug report we could give attention to?

sheldonkreger’s picture

I agree. heddn's explanation is on point. Appropriate to move this to Views issue queue?

sheldonkreger’s picture

As an experiment, I tried to execute a views_invalidate_cache() if the $pager_array returned an invalid response. Inside the render function of this module, It always sends 1 => 0 when the pager is broken. Even when my condition was met, the views_invalidate_cache() always failed. I thought I might be able to manually flush out the broken view cache, but this strategy didn't work at all.

sheldonkreger’s picture

I spent a few hours step-debugging this and found the code at fault. There is some strange code inside views.inc, which fails when the page is clicked. It's an if/else statement with no code to execute if the condition is TRUE:

(Starting at line 1219 of views.inc)

    if ($cache && $cache->cache_get('output')) {
    }
    else {
      if ($cache) {
        $cache->cache_start();
      }

The code fails sometime during the cache_get('output')

Edit: add line number.

Rizwan Siddiquee’s picture

In lite pager put offset =1
otherwise clear all cache.

berndlosert’s picture

I have attached a patch that I made at work to fix this problem. The patch forces views_litepager to calculate the $pager_total and $pager_page_array in the pre_render() method instead of the post_execute() method since the latter method is not called on views having query cache enabled. Also, since the "Page 0" problem results from $pager_page_array[$pager_id] having a value of -1, a check for this was added that calls the set_current_page() method in order to restore $pager_page_array to what it should be set to. This patch was made for views_litepager-7.x-3.0, but I believe it works with the dev version as well.

ShaxA’s picture

Patch looks good but also we need to set the current page if we have hit the last page.

q0rban’s picture

Status: Active » Reviewed & tested by the community

Tested and verified the patch in #20.

jmac99999’s picture

I also tested the patch in #20. Seems to be working fine. I am using Views cache, time based, and it wasn't working before the patch and it is now, so thanks for that.

interdruper’s picture

#19/#20 fixes the issue for me: running a couple of view blocks with litepagers in the same page, Ajax and views content cache enabled on both. Thx @berndlosert & @ShaxA!

mulderjoe’s picture

Used #20. Works like a charm. Thanks!

StephenRobinson’s picture

Used #20, too!

Anybody’s picture

@Maintainer: Would you be so nice to create a new release containing #20?

Otherwise I'd offer my help as co-maintainer to create one.

darvanen’s picture

  • ram4nd committed 3ac646c on 7.x-3.x authored by ShaxA
    Issue #2285591 by ShaxA, Peter Törnstrand, q0rban: Going back to "Page 1...
ram4nd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.