Project:Paging
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

If using automatic-via-character-count paging there is the potential of losing pages because of the use of node_teaser(). For example if maxcount is say 3000 characters and the node body is 5000 characters paging will decide to be 2 pages, however node_teaser() may decide to make the first page only 1900 characters long because say the next paragraph is too long. That leaves at least 100 characters (and potentially many more) that need to go on a 3rd page that isn't going to get created.

Attached is a patch that fixes that. Included in the patch is some code that will allow any page past the first to combine their results with the previous page if there is very little text on the page (less then 1/10 of maxchars). Maybe thats not needed, but was very useful for me :)

AttachmentSize
paging.module.patch1.12 KB

Comments

#1

Was running into the same situation and this patch appears to fix the problem. Thanks!

#2

We recently started using this module and ran into the same issue. The problem lies with the calculation of $breaks and the fact that the loop uses it as a its control variable. The correct algorithm would be to loop until $body is empty. Something like this:

          // Check if pagination is possible.
          if ($total_chars > $max_chars) {
            $body = $node_body;
            $bodypart = array();
            $i = 0;
            while ($body) {
              $bodypart[$i] = _paging_body_shift($body, $max_chars);
              $bodycount = strlen($bodypart[$i]);
              $body = substr($body, $bodycount);
              $i++;
            }
            $body_parts = implode($paging_separator, $bodypart);

#3

I tried to use patch described here and it fix problem with pages. But I have a problem then I try to insert the teaser manually in FCKEditor. In that case I have an infinity loop and 100% load of CPU then timeout for php is reached the error is issued
Fatal error: Maximum execution time of 120 seconds exceeded in \sites\all\modules\paging\paging.module  on line 474
the line number is variable from time to time, but this number is inside the "while" loop.

I use 6.x-1.0-beta3 version.

UPD. I have installed 6.x-1.x-dev version and applied patch from #2. It works fine for me.

#4

With the paging module generating automatic page breaks, the last page of a publication was omitted.(Paging module - development version 25 feb 2011, Drupal 6.20)

This publication contained rather big blocks of html (about 1500 characters) and as a result the pagebreaks were rather irregular divided.

Patch #2 solved the problem and contains in my opinion the correct way to count the pages. Thanks for publication rmjiv!

nobody click here