This is a patch to fix issue reporte in #12 of #2491949: Pager missing.

In some cases, line 74 of views_pdf.install in version 1.6 of Views PDF results in display_options['pager'] = NULL;. This breaks the View.

This NULL value happens if the pdf display's display_options['pager'] was not previously set (that is, if the PDF view pager was untouched and was the same as the Master)

This patch checks to see if display_options['pager'] pager was previously set. If it was, then it adds a FALSE in the defaults to indicate that this display's pager is not the same as the Master. If it wasn't (i.e. the pdf display had the default pager), then it leaves everything intact, resulting in the default pager still being used in the pdf display after the update.

I've tested both scenarios before the database update: an untouched pager in the pdf display, and a pdf display with a modified original pager. Works fine.

Patch in the next comment

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

argiepiano created an issue. See original summary.

argiepiano’s picture

Patch attached

argiepiano’s picture

Status: Active » Needs work
argiepiano’s picture

Status: Needs work » Needs review
argiepiano’s picture

The issue is a bit more complex than this - we will need to provide a new hook_update_N since this fix will make it into the next version of the project.

And we will need to get rid of function views_pdf_update_7000() included in version 1.6 (BTW, "7000" is the wrong N - see hook_update_N).

I'll work on a better patch tomorrow. Night night.

argiepiano’s picture

I'm now attaching a patch that replaces the faulty function views_pdf_update_7000(). This patch should make it into version 7.x-1,7.

Here's an explanation of what the arrays views display_options['pager'] and display_options['defaults'] look like in each of the last versions of views_pdf.
While this may be obvious for some, learning about these helped me create this patch. Hopefully I got it right!

In version 7.x-1.5

- When the pager of the PDF display is "untouched" (meaning that it's the default "Display a specified number of items | 10") the arrays display_options['pager'] and display_options['defaults'] are NOT set at all.
- When user changes to the pdf pager to "Display all" items" (the only other option in version 1.5) the pdf display contains display_options['pager'] but no display_options['defaults'] array.

In version 7.x-1.6
- After updating, if the PDF display pager was "untouched" before update, display_options['pager'] is wrongly set to NULL (which breaks the display), and display_options['defaults']['pager'] is set to FALSE

- After updating, if the PDF display pager had been modified to "Display all items" before update, display_options['pager'] left unchanged, and display_options['defaults']['pager'] is set to FALSE

With the new patch (hopefully version 7.x-1.7)
- After updating, if the PDF display pager was "untouched" before update, display_options['pager'] and display_options['defaults'] are not added at all, resulting in a pager that matches the Master's

- After updating, if the PDF display pager had been modified to something different from the Master, or to "Display all items" before update, display_options['pager'] is left alone (it existed), and the update function checks to see if display_options['defaults']['pager'] and display_options['defaults']['options'] existed. If they don't exist they are added with FALSE value to indicate the pager is different from the Master.

vegansupreme’s picture

Status: Needs review » Fixed

Great job Argiepiano! Thanks for taking a deep look at this issue and figuring out and explaining exactly how the pager system works!

argiepiano’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

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