In my module, I am causing a case where $view->query->pager can be NULL inside template_preprocess_views_view(). Whereas $view->query->render_pager() does already guard against an empty NULL pager, the AJAX-specific code on line 124
'pager_element' => $view->query->pager->get_pager_id(),
does not. Attached is a patch to fix this.
Thanks for your consideration.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | views-pager-theme-guard.patch | 4.03 KB | infojunkie |
| #5 | views-pager-theme-guard.patch | 1.34 KB | dawehner |
| #4 | views_pager.test | 2.59 KB | infojunkie |
| views-pager-theme-guard.patch | 589 bytes | infojunkie |
Comments
Comment #1
dawehnerIs there a reason why you use isset and query::render_pager uses empty to check the pager?
Would it be able to write a simpletest for this :)
Comment #2
infojunkieNo reason: coding idioms I guess :-)
About the simpletest: sure! Can you explain briefly how to run the tests in the views/tests folder?
Comment #3
dawehnerYou have to install http://drupal.org/project/simpletest
Therefore you need also a core patch.
Comment #4
infojunkieTest attached: I render the basic view, once with a normal pager, and another by NULLifying the pager after execution and before rendering. Before the patch, the second test fails with an exception. After the patch, both tests pass.
This is my first test, so please let me know if I ommitted something :-)
Comment #5
dawehnerThx. You should perhaps also test whether ther variable is set in the rendered html output.
Here is a patch for the patch + test.
Comment #6
infojunkieAttached is a patch that checks for the existence of the pager element in the generated HTML. Note that the view throws 5 notices when rendered, one for each row - these notices also appear when rendering a similar view on the page through the UI. It is an unrelated problem AFAICT.
Comment #7
merlinofchaos commentedShouldn't get_pager_id() return a 0 instead of a NULL? WE can do the check there, and then clients never have to worry about it.
Comment #8
dawehnerSo way earl is wrong here:
1) you cannot call get_pager_id here because query->pager is not defined here
2) get_pager_id already returns 0
:)
For me this patch looks rtbc
Comment #9
merlinofchaos commentedApplied to 6.x-3.x -- doesn't apply to 7.x but is hopefully an easy fix. Marking for porting.
Comment #10
dawehnerIt was easy