Forums / General / Paging problem in 4.4 version

Paging problem in 4.4 version

Author Message

Aleksy Goroszko

Monday 06 December 2010 3:01:46 pm

Hi,

I've just upgraded 4.2 to 4.4 and found problem with paging when inserting file to the article:

in my Media folders are some subfolders with files. One of them contains 32 files. So I want to insert some files to my article.

Edit article > Insert/Edit object button > (popup appears) > tab "Browse" > Media > Files > some my folders > Files list

This files list contains 10 files and "Next >>". I expect that it switches to the next page and that's happening. But next page contains next 10 files and only "Previous" link (no Next link). When I click Previous, I am back on the first page. But then, when I click Next again, I can see only empty page with no files.

I think that there is a bug, or did I miss something? Did anyone struggle with that?

Aleksy

Christian Pfeffer Gjengedal

Tuesday 07 December 2010 1:00:48 am

If you take a look at the Net section of Firebug, do you see any errors in the XHR communication with the server?

Nicolas Pastorino

Tuesday 07 December 2010 1:14:43 am

Hi Aleksy, and welcome for you first post here !

Let us know if Christian's hint helped find the issue,
Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Aleksy Goroszko

Tuesday 07 December 2010 1:38:47 pm

"

If you take a look at the Net section of Firebug, do you see any errors in the XHR communication with the server?

"

Hi, Christian

No, there are no errors. It just look like paging could be calculated wrong. When I follow JSON messaging of POST requests, I can see that:

1. When I open the first page (10 files + pager 'Next' ), there are parameters of call:

- content.count = 10

- content.limit = 10

- content.offset = 0

- content.total_count = 28

2. When I click "Next", I see next 10 files and pager "Previous", but no "Next" (I'd expect it - the number of files is 28 in this folder). This page contains files no 9,10 from previous page on positions 1,2. And parameters are:

- content.count = 10

- content.limit = 10

- content.offset = 8 (I think it should be 10, for elements 11-20, but it explains why files 9,10 from previous page are visible here again)

- content.total_count = 28

3. When I click "Previous", I come back to first page, but I see 10 files starting from file no 3 (!). First two from step 1 are skipped. Parameters are:

- content.count = 10

- content.limit = 10

- content.offset = -2 (sure, 8 - 10 = -2 but it has to be 0)

- content.total_count = 28

4. And now... When I click again to the "Next" pager, I can see only empty page with "Next" pager shown (clicking on it takes no effect). Parameters are:

- content.count = 0 (sure, no files on the page)

- content.limit = 10

- content.offset = -210 (!!!)

- content.total_count = 28

As I see, when I click "Next" pager, offset is calculated wrong. And it is not possible to go to the pages 3, 4, ... Maybe I need to report it as a bug?

Christian Pfeffer Gjengedal

Wednesday 08 December 2010 1:06:23 am

Hi Aleksy, yes, this sounds like a bug.

Could you please register an issue for this in http://issues.ez.no and paste the issue number into this thread?

Łukasz Kęska

Wednesday 11 May 2011 7:43:57 am

"

Hi Aleksy, yes, this sounds like a bug.

Could you please register an issue for this in http://issues.ez.no and paste the issue number into this thread?

"

Well, I've check the problem and found the solution.

The problem is in browseCallBack function of eZOEPopupUtils class - there's a part with adding offset and limit variables to get the next part of list (e.g. offset value is 10 and limit is 10, we should get the sum of 20), but instead of adding integers, they join strings together (so with numbers above we will get 1010 instead 20).

This is how it looks:

if ( (data.content['offset'] + data.content['limit']) < data.content['total_count'] )
{
tag = document.createElement("a");
tag.setAttribute('href', 'JavaScript:eZOEPopupUtils.' + fn + (data.content['offset'] + data.content['limit']) + ');');

...

To fix a problem, change the code as below:

if ( (parseInt(data.content['offset']) + parseInt(data.content['limit'])) < data.content['total_count'] )
{
tag = document.createElement("a");
tag.setAttribute('href', 'JavaScript:eZOEPopupUtils.' + fn + (parseInt(data.content['offset']) + parseInt(data.content['limit'])) + ');' );
...

greetz

Lucas