If a view returns no results this leads to following error messages:
* Notice: Undefined offset: 0 in theme_pager() (line 322 of W:\htdocs\eurocentres\drupal\includes\pager.inc).
* Notice: Undefined offset: 0 in theme_pager_first() (line 446 of W:\htdocs\eurocentres\drupal\includes\pager.inc).
* Notice: Undefined offset: 0 in theme_pager_previous() (line 476 of W:\htdocs\eurocentres\drupal\includes\pager.inc).
* Notice: Undefined offset: 0 in theme_pager_next() (line 515 of W:\htdocs\eurocentres\drupal\includes\pager.inc).
* Notice: Undefined offset: 0 in theme_pager_next() (line 516 of W:\htdocs\eurocentres\drupal\includes\pager.inc).
* Notice: Undefined offset: 0 in theme_pager_last() (line 551 of W:\htdocs\eurocentres\drupal\includes\pager.inc).
The attached patch uses the same construct like other modules (e.g. devel) to prevent this.
But I'm unsure if it would be better to use appropriate checks in the pager functions itself. Suggestions? :)
Cheers,
Peter
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 903466-16-views-plugin-pager-id.patch | 3.58 KB | theo_ |
| #10 | views-pager-with-missing-id-903466-10.patch | 995 bytes | jwilson3 |
| #9 | screen.jpg | 130.66 KB | countach |
| #5 | pager-plugin-full.90366.patch | 821 bytes | elly |
| views_plugin_pager_full.inc-prevent-undefined-offset.patch | 833 bytes | das-peter |
Comments
Comment #1
dawehnerupdate status
Comment #2
dawehnerLooks fine. Thanks for the patch
Comment #4
chaloum commentedIm having the same issue even though I have blog entries.. I am wondering how to install the patch> read the page on applying patches http://drupal.org/node/60818 but when I run the command I get
can't find file to patch at input line 10
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|### Eclipse Workspace Patch 1.0
|#P views
|Index: plugins/views_plugin_pager_full.inc
|===================================================================
|RCS file: /cvs/drupal/contributions/modules/views/plugins/Attic/views_plugin_pager_full.inc,v
|retrieving revision 1.1.4.7
|diff -u -r1.1.4.7 views_plugin_pager_full.inc
|--- plugins/views_plugin_pager_full.inc 22 Mar 2010 20:25:10 -0000 1.1.4.7
|+++ plugins/views_plugin_pager_full.inc 6 Sep 2010 13:14:03 -0000
--------------------------
File to patch:
I have no Idea what is going on as I thought the patch file views_plugin_pager_full.inc-prevent-undefined-offset.patch was the patch.
Any help would be appreciated
thanks
Marcel
Comment #5
elly commentedJust ran into this - looks like there is a small typo in views_plugin_pager_full.inc that is causing this bug to crop up again. First noticed it because page containing the view was timing out. This was the error in my logs:
Here's a patch against 7.x-3.x-dev.
Comment #6
elly commentedOops, setting back to active. MAybe should have made a new issue...
Comment #7
dawehnerThe code below fills in the values already, maybe your patch should be adapted a bit.
Please also reroll your patch, so the testbot can test it.
Comment #9
countach commentedI have the same issue after using search twice with 0 results. The errors are thrown only on pages which contain pagers (like paged blocks). Patches posted above don't work :(
Comment #10
jwilson3Hitting this same error in #5 above, with a pager used on a views panel pane, with an exposed setting for pager offset. If the panel pane doesn't specifically set the offset, the options['id'] is just an empty string (which breaks line 233).
This patch creates a
$pager_idwith this specific case in mind. the variable is then used in the for loop and on line 233.Comment #11
jwilson3Note, the patch in #10 was applied against an earlier version of views, and should still apply to 7.x-3.x-dev with offset (i just reapplied it to 7.x-3.3, with offset).
Comment #12
jwilson3-- deleted, double post.
Comment #13
dawehnerWell actually $this->options['id'] should be always set from the views side, maybe panels is doing something wrong.
You know fixing just a notice might hide other bugs, at least in my experience.
Comment #14
das-peter commentedI experienced the same issue, but as far as I remember the error is located in the ctools views content pane.
The code of
ctools/views_content/plugins/content_types/views.inc&ctools/views_content/plugins/content_types/views_panes.incseems to use some views 2.x code.E.g.
views_content_views_panes_add_defaults()fetches the pager id by usingelement_id($view->display_handler->get_option('element_id')) insteadid.But in
views_content_views_panes_content_type_render()the pager id is set back properly asid.This means if you don't set manually the pager id to 0 it will use an empty string as id since this is what's returned by
$view->display_handler->get_option('element_id').My guess is that the code that defines default values wasn't properly updated during the 2.x to 3.x migration.
Comment #15
errev commentedviews_plugin_pager_full.inc-prevent-undefined-offset.patch queued for re-testing.
Comment #16
theo_ commentedI just run across this bug.
To reproduce it :
Now trying to access page 2, you'll probably face this error:
After digging into views_plugin_pager, I found the get_pager_id() method which is great but almost never used.
So here is a patch that make use of this method to ensure we never use an empty pager id.
Comment #17
dawehnerThis is a great fix!
Comment #18
hanksterr7 commentedI am still seeing this error
I reviewed the patch in #16 and I find those changes to be already part my current Views implementation (v7.x-3.8), so I have nothing to patch.
My scenario that causes the error may be a bit different from what started this thread. I create a view containing a block, and add that block to Left Sidebar, showing on all pages. I use a Full pager in the view/block definition, and I set the pager id for the pager in the block to 1. (I need to set the pager id since the main portion of whatever page the block shows on can have its own pager, and each pager on a page needs to have a unique pager id or else the pagers talk to one another when you changes pages).
If I type a nonsense string into the main Search box and do a search that returns no results, I get the "Undefined offset: 0 in theme_pager()" error. If I remove the new block from Left Sidebar, the error does not happen.
I'm assuming the Search Results page is failing to set some variable when there are no search results for the pager that would normally be associated with the list of search results, and that unset variable is being processed by the extra block (with pager) that I have added to the page and which then causes the error.
So, this is probably a Search error in its use of a pager. But should the pager code in Views detect this state and fail gracefully?
Thanks for your thoughts
Comment #19
lendudeMoving this back to the 7.x-3.x queue
Checked D8 core and getPagerId() is present but never used, while $this->options['id'] is used all over the pagers.
No Notice is given when using an empty Pager ID, but the pager doesn't work either. Will open a new issue for that in the Drupal core 8.0.x queue (and maybe use getPagerId in that .