Reviewed & tested by the community
Project:
Custom Pagers
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Sep 2011 at 02:24 UTC
Updated:
13 May 2020 at 16:03 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
megan_m commentedSame, and I'm running on LAMP. I get 4 of the "Notice: Undefined property: stdClass::$nid" errors followed by 5 of the "Notice: Undefined offset: -1 in pager_entries_by_key() " errors. And no pager shows up.
Comment #2
troybthompson commentedSame
Comment #3
desierto commentedI also get these errors. I created a single pager for a single content type and used a view to populate the pager.
I got 10 of the first error and 5 of the second. This module is badly needed... so THANKS for working on it.
Here is an example of my errors:
Comment #4
anthonyR commentedSame story, I'm getting couple of both errors as well.
I'm using a custom pager for a specific content type, populating the pager items with a view.
Comment #5
santam commentedsubscribe. The pager also doesnot appear below the node or in the block. I also tried placing the block using panels but it doesnot show up
Comment #6
kelvinleehk commented+1
Comment #7
diego21 commentedSame as #3. I'm running a LAMP too and userd above pager
Comment #8
sw3b commentedSame here !
Comment #9
IWasBornToWin commentedSame here
Comment #10
matter9 commentedsame here. 9/22 release doesn't work.
Comment #11
dgastudio commentedsame here, doesnt work
Comment #12
alekiv commentedsame here
Comment #13
Anonymous (not verified) commented+1
Comment #14
k4v commentedThere was a change in views api, I fixed custom_pagers_plugin_style_php_array.inc (thanks dereine).
Comment #15
k4v commentedComment #16
hydra commentedThis patch is looking perfectly fine to me! It also worked as expected, should be go into the module!
Comment #17
diego21 commentedDon't work for me. I have new 7.9 core on a LAMP. Show this erros with this patch
I'm trying to help, but I don't understand almost anything.
Comment #18
hydra commenteddiego21: did you use the actual (git) dev versions of all modules? (views, ctools and custom_pagers)
Comment #19
2dareis2do commentedAny idea when and if this patch might be added to the next build?
Comment #20
diego21 commentedHydra: is that necesary? I don't want to compromise my all site with dev versions of this modules.Does this module needs the other modules to update their versions to work well? Why use functions or features not yet stable?
Comment #21
hydra commented@diego21: you should at least test it, befor you post that the patch would not work. Its recommandable to use dev versions of ctools and views, beacause there are some hundret bugs less then in stable....
About custom_pagers and the patch, new patches are always developed for the latest dev. So to answer your question, yeah its necessary ;) I would not see this as a compromise, in my opinion its best practise (at least for thoose modules)
The problem here is, I think, that views/ctools did some changes in theirs api. The patch uses already the new api requirements, and how I said, the dev versions are more stable then the stable version ;)
Comment #22
diego21 commentedSame problems with git versions of all modules. Any idea? Here is the full list of warnings and notices:
Comment #23
diego21 commentedOk, I could fix almost all errors. I change the function to this:
Leaving the function uses_fields() as it was in the patch. I just remove "['rows']" because this index don't exist in my case. With this change I fix it for some views in my site, with others, the last five notices still appear. I have to say that in my particular case, a type of node shows up in different views, I guess here is my problem. The module seems don't work well with that cases.
On the other hand, with my "normal" views the pager doesn't render properly. It does it right side of the first field in my node content, I thought I must render even before the author (at the top of my node type). Well, I'll keep trying and searching solutions.
Comment #24
hydra commentedWell this is an approach and a description wich gives us the opportunity to rebuild your case.
Your changes removed all changes the patch made ;) So this may not be the solution. Will have a look at this
Comment #25
hydra commentedOkay there, now I had the issue wit h the 'row' array, too. Remoing this solved most of the problems. The users_fields() function is still neseccery to tell views, that the diplay could have fields.
Is there any reason that in custom_pagers.module line 268+ the key is reset to -1? If I switch this to 0, all works fine. Can you confirm this diego21?
Comment #26
diego21 commentedHydra: Well, the pach adds the uses_fields() function ;). I did it, and the notices don't appear. I realised of that too, but didn't apply because in custom_pagers.module lines 88+ and 166+ there is a check:
And I suppouse that the -1 of $key in line 268+ is for that. When I change this value, the notices don't appear but the pagers neighter. This happend with my "special" node types, which show up in more than one view. And the render place is still wrong in my "normal" nodes. Where does your pager render?
Comment #27
13rac1 commentedCritical is valid in this case since the module is unusable with Views, and will break functionality on a site upgrade.
Attached is a patch which changes uses fields in custom_pagers.views.inc. Seems as though the issues above were caused by changing it in custom_pagers_plugin_style_php_array.inc
Comment #28
theneonlobster commentedI can confirm that this patch works.
LAMP
Drupal 7.8
Views 7.x-3.0-rc1
CTools 7.x-1.0-rc1
Custom Pagers 7.x-1.x-dev
Comment #29
k4v commentedHi,
okay, I tried patch #27 and removed my changes from #14
seems to work now but on one of my pager views I get this error:
in the array $list there is no entry with index -1...
Comment #30
13rac1 commented@k4v, please use a current checkout of the git repo. There is only a bracket at line 289 on custom_pagers.module, therefore your code base is out of date or incorrect. (Although the error may still be valid)
Comment #31
k4v commented@eosrei:
i had just some debug output in the file. i pulled the git version again. here is the error
it seems to happen only with a specific article, thats missing from the list in custom pagers... but it appears in the view....
Comment #32
k4v commentedThe first error in Line 163 I fixed with:
Comment #33
13rac1 commentedI was going to suggest isset() for that first error. I suspect the second error will be slightly more complex. I can't reproduce, so I can't debug. If you tell me what else to to change, I'll make a new patch so you can RTBC it.
Comment #34
diego21 commentedeosrei: As I said above I have the same errors as #29. Maybe it happens because a node appears in more than one view. Can you confirm this, k4v? I have a view just for list articles, my articles don't appear in any other view, and custom_pagers works "almost" perfect (without errors) in that case.
Comment #35
k4v commented@diego21: strange thing: the error has to do with some nodes i create new, for older nodes pagers work okay... i tried to find differences between the nodes that work and the nodes that produce the error, but could not find it yet.
this error occurs because the current node itself is not included in the list the module generates. i can see the node in the view correctly, but its not in the array, therefor the -1 is set...
Comment #36
k4v commentedokay, i my theory is the list only grows to 10 entries (0 to 9), the additional nodes produce the error...
update: yes, i can reproduce it on a different drupal installation. for the 11th node, the error appears =).
Comment #37
diego21 commented@k4v: I could see that the list the module generates is ok just for nodes included in one view. In my case, for nodes includes in more than one view, the module generates more than one list...and the number of nodes in this lists seems be random. I don't understand why this occurs. Your older nodes are included just in one view?
Comment #38
diego21 commentedok k4v, I'll add more nodes to try probe your theory :-)
Comment #39
k4v commentedim quite sure this is the problem: as soon the view returns more then ten items, the last items produce the error.
Comment #40
diego21 commentedchecked. k4v, you rules ^^, there is a problem here. But I can specify a little bit your theory. I have a view for articles, when I created a pager for it I just had 5 articles...so...as your theory says the pagers worked ok. I have started to add new articles...one by one...watching the generates list. Until the tenth element the list was perfect, but when I added one more...the generated list lost the oldest element. Now, my view of articles shows his pagers without errors, but my first articles are out of the pager.
Comment #41
k4v commentedits the pager of the view object...
in line 320
$view->pager['items_per_page'] = 0;
this obviously does not work anymore, the default value is 10...
Comment #42
diego21 commentedSo the try to remove this restriction fails, and the items per page of the view must prevail. But in my view, the items per page is set to 5. Why the list the module generates is limited to 10 elements?
Comment #43
diego21 commentedI changed it to
and works ok. Its the correct function according to Views 2 API
Comment #44
diego21 commentedThis just work for nodes in one view, still the offset -1 error in my others views :S
Comment #45
k4v commentedyes! thanks diego =). I did not find this views method. views is still mysterious to me...
Comment #46
k4v commentedoh what? for me it works....
.... did you clear all caches? =)
Comment #47
diego21 commentedWithout your help I haven't find anything ^^. Can you confirm if your nodes just appear in one view? You can create another sample view, and change one simple thing...a filter or a sort option. Then check if still works
....yea...I did it ;)
Comment #48
k4v commented@diego: in my testsystem, I cloned the view and created a new pager. In the clone I reversed the sort order. It works fine. did you check, you have no limts in your view? In the view for the pager, you should not the number of results....
Comment #49
diego21 commented@k4v: Sorry, don't understand your question. Limits? Don't know what do you mean.
Comment #50
k4v commented@diego: in #42 you wrote: "But in my view, the items per page is set to 5". Try to set it to unlimited items.
Comment #51
diego21 commentedI did it, don't work. That was my correct view, my articles view. My other views has pager limit set to 15, but I changed to unlimited and didn't work.I think my problem is which I said in #37, but if you cloned a view and works ok...
Comment #52
diego21 commentedOk. I tried something. Cloned my articles view, change sort order, and added a new pager for it. If I access original view from its menu item...pager works ok, and the list generated by module has a new Array with the same number of nodes but in invert order. If I access cloned view from its item menu...pagers don't works: the list is printed ok( I add a trace to see the module list result, is the same list the other view prints), but the pager don't render ok (the view has 12 nodes)
< previous 12 of 121 of 12 next >
It seems print two pagers: ( < previous 12 of 12) and (1 of 12 next >) joined. The correct would be the second. Why this happens? Another strange behavior ^^
Comment #53
13rac1 commentedNice to see everyone working on this issue.
@diego21 in #43: It is the same function call, but since this is D7, Views is at V3.
@k4v in #50: It doesn't matter how many items per page you set in Views, Custom Pager uses it's own display plugin which automatically resets the items per page value.
I was finally able to reproduce the "Notice: Undefined offset: -1 in pager_entries_by_key" problem. Attached is an updated patch including the $view->set_items_per_page() function. My pagers all work correctly now.
If you are still having issues(after applying this patch), please thoroughly describe how to reproduce, so I/we can continue to debug.
Comment #54
diego21 commented@eosrei: I know D7 uses Views 3, but I can't find Views 3 API because it's still under developing, I just wanted say where I found the function, but your welcome.
The "Notice: Undefined offset: -1" persist. I don't know why but for my case...persist. If you want another issue to debug, read my post #52, just create a few views for the same type of content changing the sort order or something, then create a custom pagers for each view. When you visit one of this types of nodes, you will see a few pagers rendered joined, that is suppose to be the key of this module... but doesn't work. If I'm wrong and you just can use custom_pagers for one type of node in one only view... isn't too useful.
Comment #55
k4v commentedHi, I just revied the patch and tested it on my production environment. All fine, in custom_pagers.module, Line 163 please add
if (isset($pagers[$delta]) && $pager = $pagers[$delta]) {Comment #56
13rac1 commentedI determined a way to reproduce this error, and the above change doesn't correct the -1 errors in my instance.
Comment #57
13rac1 commentedFinally had a chance to really look at this code, since the project needing it has launched.
I figured out the problem! Line 225:
Guess what happens when the pager is supposed to be shown on 'gallery_image', but you've also got a 'image' content type? $visible = TRUE; HAHA!
I converted the comma delimited list of content types into an array with explode() and checked for visibility with in_array(). I made as few changes as possible to correct this issue. There are still many minor issues I'd like to correct, but they aren't necessary to get a working version.
Comment #58
13rac1 commentedPlease make a new issue for the double pager problem in #52. This issue should be just about getting the D7 version working in most uses cases.
Comment #59
13rac1 commentedDiscovered another way to get the Notice: Undefined offset: -1 notices. I added a check to make sure the array is not empty, which should make these notices impossible now.
Comment #60
diego21 commentedI thought it worked, but "Notice: Undefined offset -1" persist.
Comment #61
13rac1 commentedPlease document how to reproduce, or work through the debug process and tell me what to change in the patch. I don't see these notices at all anymore.
Comment #62
2dareis2do commentedThis works for me. Removed the previous patch (#14). Applied #27. However this seems to be restricted to the first 10 items or nodes. After that I receive the following:
Comment #63
valderama commentedTested the patch form #59 and works fine here (big thanks, btw!).
Using
- D7.8
- views 7.x-3.0-rc1
- ctools 7.x-1.0-rc1
UPDATE:
I updated core and modules, now I am using
- D7.9
- Views 7.x-3.0-rc3
- CTools 7.x-1.0-rc1
And custom_pagers is still working :)
Comment #64
zach harkey commentedAlso tested the patch from #59 and can confirm that it works.
Drupal 7.10, Views 7.x-3.0-rc3, CTools 7.x-1.0-rc1
Comment #65
drizzi commentedhello guys,
can anyone add the patch and release a new version of the modul ?
after (hopefully correctly applying the patch) the above mentioned errors disappeared - but the pagers too. clearing the cache did not help.
Instead, i recieved an error in customs pagers gui:
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (Zeile 1552 von /var/www/web33/html/v2/includes/bootstrap.inc).
does anyone know how to handle these 2 problems?
best regards and thanks
steffen
Comment #66
zach harkey commentedAfter applying the patch, try disabling and uninstalling the module, then reenable and recreate your pager.
Comment #67
drizzi commentedHello Zach,
thanks for your comment - but i am still getting the same error.
steffen
Comment #68
EvanDonovan commentedJust wanted to add another confirmation that the patch from #59 resolves these issues.
Comment #69
IWasBornToWin commentedI just install dev for drupal 7, cleared cache and got all the errors. Has patch from #59 been added yet?
Comment #70
13rac1 commented@IWasBornToWin: The maintainer will set the issue status to Fixed once the patch in #59 is committed.
Comment #71
rasumo commentedDoes the patch in #59 still apply? Tried using it on current dev and fails.
Comment #72
kelvinleehk commentedI'm seeing the same error too after applying patch in #59.
Comment #73
pjnes commentedTried applying the patch in #59 on D7.10 and still getting the same error.
Comment #74
2dareis2do commentedThis is all too confusing. Which patch(es) do we have to apply?
Using flippy module for now.
Comment #75
ghmercado commentedpatch at #53 worked for me.
to apply a patch using terminal:
hth
Comment #76
rggoode commentedsubscribe
Comment #77
13rac1 commented@rggoode: Please stop subscribing, and start following: http://drupal.org/node/1306444
Comment #78
sw3b commented#59 who also include #53 solve all my problem for me.
Comment #79
nirad commentedgetting the same error as drizzi in #65 after patching using #59
Comment #80
Yuri commentedGot same problem as #65 after installing patch #59
Comment #81
d0t15t commentedPatch from #59 is successful for me.
drupal 7.12
views 7.x-3.3
ctools 7.x-1.0-rc1
7.x-1.x-dev
Comment #82
13rac1 commentedYuri, nirad, Pjnes, sourcesqr & rasumo: If you are still having a problem after applying my patch in #59, then you must thoroughly document how to reproduce the issue.
Comment #83
edrupal commentedPatch from #59 worked for me but introduced a new issue. I now get the warning message
Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1572 of C:\Users\Ed\Documents\www\Areen\website\includes\bootstrap.inc).when on the custom pager administration page.
Drupal 7.12
views 7.x-3.3
ctools 7.x-1.0-rc1
7.x-1.x-dev
Digging a bit deeper I think the problem is in custom_pagers.admin.inc in particular the line
$row[] = !empty($pager->visibility_php) ? t('PHP snippet') : t('%node_type nodes', array('%node_type' => $pager->node_type));The variable $pager->node_type is an array, but the t() function expects it to be a string. This was one of the changes made in the patch from #59.
I changed the line to
$row[] = !empty($pager->visibility_php) ? t('PHP snippet') : t('%node_type nodes', array('%node_type' => implode(',', $pager->node_type)));and everything worked fine.
Comment #84
edrupal commentedWith ref to #83 above, here is my attempt at a patch to be applied in addition to the one in #59
Ed
Comment #85
gratefulsk commentedPatch in #59 worked for me. After applying the patch, I just made sure to disable and uninstall the module, then reenable it. Had to flush my cache twice.
Comment #86
Cynthia Ewer commentedConfirming that on a new install, applying patches 59 and 84, worked to correct the issues noted above.
Thank you!
Cynthia
Comment #87
celstonvml commentedEverything appears to be working from my standpoint using patches 59 and 84.
Comment #88
plusproduit commented#59 and #84 worked for me too (D7 views 3)
Comment #89
awasson commentedThanks to everyone above for the troubleshooting effort that produced Patch #59 and #83. I was scratching my head for a while trying to figure this one out before I came across this thread and solution. I now have a working custom pager.
Note: Patch #59 stalled out at line 68 on my system (Mac desktop) and I had to remove the forward brace in the path to views/custom_pagers.views.inc. Otherwise it works as described.
Cheers,
Andrew
Comment #90
jeffschuler#59 + #84 worked for me, too.
Combined into a single patch. No other changes.
Comment #91
steveoliver commented#90 works for me.
Comment #92
srgk commented#90 works great
Comment #93
sw3b commented#90 works great thanks !!!
Comment #94
texas-bronius commented+1 #90: the composite of the patches above
Comment #95
spazfoxAfter applying the patch in #90, I'm still receiving multiple instances of the following error:
Notice: Undefined offset: -1 in pager_entries_by_key() (line 289 of /home/mysite/public_html/dev/sites/all/modules/custom_pagers/custom_pagers.module).
Here is my setup:
Drupal 7.15
Views 7.x-3.5
Ctools 7.x-1.2
Any ideas?
Comment #96
spazfoxDisregard #95. After disabling, uninstalling, and reinstalling the patched module (and clearing my cache), the errors have gone away on my site. #90 FTW!
Comment #97
jnettik#90 works for me as well.
Comment #98
jakew commented#90 works for me. Can it be committed?
Comment #99
alforddm commented#90 for the win! Thanks so much!
Comment #100
eloivaque#90 works for me.
Comment #101
timcamps commented#90 works
Drupal: 7.16
Chaos tools: 7.x-1.2
Views: 7.x-3.5
Comment #102
Anonymous (not verified) commented#90 applies and works here, too.
Please commit the patch and release a stable D7 version.
Thanks!
Comment #103
netentropy commented#90 works for me as well
Comment #104
john bickar commented#90 RTBC.
Comment #105
pere orga#90 does not fix the issue completely for me, I still see this in some places:
Comment #106
john bickar commented@netol see #1346194: Invalid index value in function pager_entries_by_key
Comment #106.0
john bickar commentedadded second error message
Comment #107
spidersilk commentedRe committing this patch - it looks like there have been no commits on this module for over two years, and the maintainer seems to have a lot of other projects on his plate. Maybe a co-maintainer is needed?
(No, I'm not volunteering... My module development skills aren't really up to that task yet.)
Comment #108
Anonymous (not verified) commented#90 along with #106 worked for me. :)
So I thought. Until I cloned one of my views (twice). Now the clone views do not display the custom pager and the original view, displays 3 custom pagers on top of each other. Still looking for a solution. Otherwise, I am going to try deleting the views and re-creating them. Hopefully that helps.
Comment #109
awasson commented#90 worked for me as well.
Without that patch this module is pretty much useless so hopefully the maintainer will get around to committing it.
Until the patch is rolled in, there should be a statement on the project page indicating the problem with Views API and a link to the solution. I'll edit the Community docs to indicate that there is a conflict with Views API and point it to this thread.
Andrew
Comment #110
klokie commented100% agreed with the previous comment - this module works with the patch from #90, and otherwise not at all.
It took me a while to find this issue thread, so hopefully the maintainer will commit it!
Comment #111
torgospizzaI've pinged @eaton on Twitter, seems he is still the only one who is capable of making commits. Hopefully he will see this!
Comment #112
OnkelTem commentedSubscribing. But in my case I couldn't get anything until I made only one simple fix:
Gonna try the patch now.
Comment #113
OnkelTem commentedWell, I confirm that the patch #90 works with latest Views 3.11 and Drupal 7.38
Let's force committing it.
As for the functionality, well it is pretty limited. Why not to use the paging view to DISPLAY nodes in a row?
Comment #114
tijsdeboeckJust upgraded a client website from D7.10 to 7.39 and applied patch #90. Works perfectly, thanks!
Comment #115
giorgosk#90 works as expected please commit
Comment #116
xecollons commentedJust coming to say that #90 worked great! Thanks a lot!
Comment #117
asherry commented#90 still worked for us too, thanks jeffschuler
Comment #118
nwom commented#90 still works. Wish we had an active maintainer to get this committed and release a stable version of the module with security advisory policy.