Closed (duplicate)
Project:
Views PHP
Version:
7.x-2.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 May 2014 at 08:44 UTC
Updated:
24 Aug 2020 at 08:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dgroene commentedViews 7.x-3.8 changes the file plugins/views_plugin_query_default.inc to move the following code from the execute function to the query function:
if (!empty($this->limit) || !empty($this->offset)) {
// We can't have an offset without a limit, so provide a very large limit
// instead.
$limit = intval(!empty($this->limit) ? $this->limit : 999999);
$offset = intval(!empty($this->offset) ? $this->offset : 0);
$query->range($offset, $limit);
}
Therefore the query range has now already been set before the following lines in views_php's pre_execute function:
$this->wrapped->view->query->set_limit(0);
$this->wrapped->view->query->set_offset(0);
This patch takes the query by reference and changes the range to ensure that there is no limit.
Comment #2
jrochate commentedThanks!
I was about to jump over the bridge :)
Comment #3
dhansen commented#1 Patch works well for me.
Comment #4
nitrosx commentedthank you, thank you, thank you.
I finally tracked the issue down to this module. Your pager saved me a good deal of time.
Comment #5
mas0h commented#1 Works for me.
Thanks!
Comment #6
pmchristensen commentedCorrected patch so it works with drush.make files. Patches should be made from within the module folder.
Comment #7
dosed commentedCan confirm #1 is working.
Thank you so much for this!
Comment #8
fchometonConfirm that #1 works for me.
Thank you.
Comment #9
jaykaycgn commentedMany thanks to @dgroene for that patch #1 - works like a charm!
Comment #10
GinaF commentedCan't thank you enough! #1 sorted me too.
Comment #11
codesmithThis seems to work for the "paged output" options but does not seem to work for the "Display a specified number of items" option.
Comment #12
sense-designThis needs to be fixed in 7.x-1.x also
Comment #13
haroldsanchezb commentedHello, I have a problem.
apply the patch, the pager does appear, but now, the content of the view don't appears, my view is a search api.
mi views is version = "7.x-3.7+27-dev"
mi views_php is version = "7.x-2.x-dev"
Comment #14
deggertsen commented#6 fixed it for me. Thank you!
Comment #15
wOOge commentedConfirmed. #6 worked for me as well.
Comment #16
d.sibaud commented#6 works great, thanks dgroene
Comment #17
jmrivero commentedThis fix works with 7.x-1.x-dev aswell, but in one of the views I got a php error about $query not being an object, fixed it like this:
Comment #18
sakiland commented#1 and #6 work for me. Thank you very much.
I've had some issue to apply patch via Netbeans, so I've manually applied and it works like a charm.
Comment #19
drupalbabaji commented#6 worked for me. Thank you very much.
Comment #20
Anonymous (not verified) commented#6 worked for me
Comment #21
FAAREIA commentedThanks. #6 worked. =)
Comment #22
bisw commented#6 worked for me. Thank you very much.
Comment #23
deggertsen commentedI think this can safely be set to RTBC. I've been using this patch for a month now without any problems and would like to make sure that it's included in any new releases.
Comment #24
johnvComment #25
crystaldawn commentedPatch in #6 did not work in my case. Disabling views_php makes the pager come back, but re-enabling it makes it disappear again. Applying this patch did nothing.
Comment #26
crystaldawn commentedComment #27
crystaldawn commentedAfter further review, I was correct, this patch does nothing in my case. The correct patch for this issue can be found here:
https://www.drupal.org/node/2123315#comment-8193007
https://www.drupal.org/files/issues/2123315-Views-PHP-Search-API-Paging_...
After applying the Search API patch, it fixes the pager disappearing act. Perhaps someone who uses the & fix can try the Search API patch and see if it works. If it does, then it's probably best to have 1 patch that rules them all rather than one that is hit-n-miss. It should also be noted that this issue's patch will not show more than 666666 results for obvious reasons which was an issue on my end as I had over 12 million results (its a log view)
Comment #28
aaronelborg commented#6 works here. Hack-city, however.
Comment #29
bryanhidalgo commented#6 works form me too.
Comment #30
jan-e commented@crystaldawn in #27: I am not using the Search API module. Either one of the two patches worked for me. But not both together: then I get all results plus superfluous pager links at the bottom of the view.
I am not sure which is the best one. The patch as #6 in this issue sets an arbitrary limit of 666666 to the query results, which did not work in your case. Curious: do not you run out-of-memory when querying for 12 million results? And which version of the Search API module are you using? There is a recent patch in that module that is related:
https://www.drupal.org/node/2146435#comment-8889247
If you apply that one and the fix in this issues #6, does it work? See the earlier analysis by timkang in https://www.drupal.org/node/2146435#comment-8271297 and his comment on the patch that worked for you at https://www.drupal.org/node/2123315#comment-8273499
Comment #31
ravi.khetri commented#6 works fine.
Comment #32
jan-e commented@crystaldawn: you changed the status away from 'Reviewed & tested by the community'. Could you at least check if #6 is working when you bring your Search API module up-to-date with this patch: https://www.drupal.org/node/2146435#comment-8889247
Comment #33
norman.lol#1/#6 worked for me with views_php 7.x-1.0-alpha1 as well.
Comment #34
cmarcera commentedI applied the patch from #1 back in the beginning of June and that worked fine to get my pagers back (thanks!) however since then my pages have been inconsistent as to which subset of data they load.
For example, this is my current authenticated user experience:
Those results are from one authenticated user's experience. I just tested two others that worked seemingly flawlessly. The biggest issue is that it's inconsistent and the only thing I know for sure is that this started when I applied the patch from #1 to get the pagers back.
Anyone else experience anything like this?
Comment #35
kiralyj commented#6 worked for me with views_php 7.x-1.0-alpha1
#1 not tested
Thanks!
Comment #36
Kiwa commentedI applied the patch in #6 to the current dev version and it worked for me.
Not only did it repair the pager on my broken views, it also solved another bug, when I couldn't limit the result to a certain number and use an offset on a view with a views_php field. Unlimited entries with an offeset would work, but not say a limit of 10 and an offset of 3. This patch solves this issue as well.
Comment #37
monaw commented#6 worked for me also.
But that appears to be a just a hack...when will a non-hack/real fix solution be done?
Comment #38
jmdeleon commentedCan confirm #6 worked for me.
Comment #39
Anonymous (not verified) commented#6 worked for me. Thanks!
Comment #40
ilgriso commented#6 worked for me with views_php 7.x-1.0-alpha1
Thank you!
Comment #41
madhura.dhole commented#1Patch works well for me.
Thank you!
Comment #42
julian.montagna commented#1Patch works well for me.
Thank you!
Comment #43
vikramy commented#6 worked. Thanks
Comment #44
willowdigit commented#6 worked for me.
Comment #45
webguy2000 commented#1Patch worked for me. Thanks!!
Comment #46
ofry commented#6 worked for me.
Comment #47
alex.bukach commentedComment #48
papagrandeI didn't try #6, but a cursory glance at it did strike me as hacky. As @Jan-E commented in #30, https://www.drupal.org/node/2123315 has a similar issue and patch so I rerolled that one at https://www.drupal.org/node/2123315#comment-9085183 and now my pager shows up.
Comment #49
gabyyy commented#6 worked for me
thanks !
Comment #50
superspring commentedThis looks like more of a bug in views. This patch is required in order to keep views_php working with it.
Marking this as RTBC as the module maintainer needs to either add this or find a new way of working with views.
Marking this as critical as IMO the module does not work if it's damaging views' pager.
Comment #51
yugi commentedThe patch in #6 really appears to be somehow hacky, especially with that 'deviled' hardcoded "666666" :)
As mentioned by @PapaGrande in #48, the patch here: https://www.drupal.org/node/2123315#comment-9085183 worked very well in my situation.
Comment #52
Samfall commentedI have multiple views that use Global:PHP, one of which displays lots of values for which the pager was broken. Another of these displays uses a limit to only show the first two results. When I used the patch in #6, it fixed the pager problem on the first page, but removed the limit from the second (showing all results). So, it worked in specific scenarios, but broke other parts of my site.
As previously mentioned by both @yugi and @PapaGrande, the patch from https://www.drupal.org/node/2123315#comment-9085183 worked for my situation without breaking things.
However, I'm also having difficulty with sorting. Since the update to the new views, my PHP sorting doesn't work across pages. It only seems to work on the contents of each page. For example, things that should be on the first page show up on the second or third, but everything on the first page is ordered correctly. I generally think this is a related issue, but can't figure out why.
Comment #53
Samfall commentedMy previous statement was a little misleading. I was trying to combine the two patches and the combination was what was causing problems. The patch here works on it's own for my circumstance (and fixes my problem with sorting!). The other patch also works on it's own (without fixing sorting), but when combined it breaks some views. I have a combined fix that I posted to the other thread.
Thanks for the fix!
Comment #54
liquidcms commentedhopefully not muddying the waters too much with this; and maybe it should be a separate issue... but i think what you have for code in the PHP field also impacts whether the pager appears or not.
I have a php field which calls a coded function. this is fine. if, in that function i call something like views_get_view_results(), even though my PHP field displays the correct value; the page does not show.
i have tested this with all the patches listed here as well as the patch from #2123315: Pager does not appear if fields use Views PHP (7.x-1.x) and also with version combinations of views_php and views going back numerous versions of both and this is an issue with all of the (amazed i have not stumbled upon this until now).
my guess is that call a view within the php field is the issue; but might explain some of the inconsistency people are seeing here.
Comment #55
liquidcms commented.. but.. i found that changing the pager id for my pager fixed my issue with the old versions of the 2 modules that i had in place OR with the latest rel of each and the patch here: https://www.drupal.org/node/2123315#comment-9085183
Comment #56
sadanand kenganal commented#6 worked for me. Thank you so much Mr.pmchristensen .
Comment #57
prashant.c#6 solved the issue it works like charm.
Comment #58
mustanggb commentedThe patch here is hacky, the real fix is over at #2123315: Pager does not appear if fields use Views PHP (7.x-1.x).
Comment #59
shamsher_alam commentedthanks buddy.
Comment #60
couloir007 commented#1 worked for me. Thank you.
Comment #61
lingaraj_m commented#1 Worked for me. Thank you.
Comment #62
yngens2 commentedNumber of users here referenced https://www.drupal.org/node/2123315, however I had this issue on a website that didn't use Search API at all. So #6 worked for me just fine.
Comment #63
maxmendez commentedThe patch #6, worked for me.
Comment #64
rcodinaPatch on #6 works for me too. Please, commit this patch ASAP, it saved my life!
@MustangGB I don't use search API and this patch solved the bug. This issue has a patch, the other hasn't. Why this can't be commited while there isn't a working patch on the other one?
Thanks!
Comment #65
rcodinaComment #66
mustanggb commented@rcodina There is a patch over there and it has nothing to do with Search API, that is just what the guy was doing when he found the issue, 2123315 #26 is the patch that solved the pager issue for me and I'd be interested to know if it works for you also: #2123315-26: Pager does not appear if fields use Views PHP (7.x-1.x)
Comment #67
user3077953 commentedAt first glance, the patch in #6 appeared to work. However:
- It will not work when there are more than 666666 results.
- In my view, I have a "Global: PHP" field, which, after applying the patch, gets called for every result, including those that are not displayed on the current page. Considering I have thousands of results, this behavior is not acceptable performance-wise.
The patch in #2123315-26: Pager does not appear if fields use Views PHP (7.x-1.x) seems to work better.
EDIT: the patch in #2123315-26: Pager does not appear if fields use Views PHP (7.x-1.x) does not actually work properly. See my comment in #2123315-42: Pager does not appear if fields use Views PHP (7.x-1.x)
Comment #68
RAWDESK commented#1 worked for me too. Thanks @dgroene!
Comment #69
davidteall commentedAny chance of a proper fix to this bug? It was first flagged up 5 months ago and we still only have a patch. I am not using Search API but all my pagers have disappeared since the upgrade to views-7.x-3.8.
Comment #70
apermuy commented#6 works form me too. Thanks a lot!!!!!
Comment #71
user3077953 commentedIn my previous comment, I was complaining about the fact that with the patch in #26, "Global: PHP" fields get called for every result, even those that are not displayed on the current page. It seems it was the normal behavior with views 3.7, so I shouldn't really complain about it.
Comment #72
okday commentedplease commit this fix
Comment #73
okday commented#6 works form me too.
Comment #74
mooru commentedYep #6 just saved me. Thanks a bunch
Comment #75
xiukun.zhou commented#6 works form me. Thanks a bunch
Comment #76
aviddv1 commented#6 works here. Thanks.
Comment #77
sadashiv commentedI think what @MustangGB says in #66 is correct i.e. patch at #6 is workaround instead of that the fix at https://www.drupal.org/comment/9085183#comment-9085183 fixes both issues.
Comment #78
leolandotan commentedThanks! Patch #6 also worked for me.
Comment #79
manuel.adan#6 works form me, thank's!
Comment #80
antims commented#6 works fine for me,thanks a lot.
Comment #81
antims commented#6 works fine for me,thanks a lot.
Comment #82
gravisrs commented#1 and #6 is not the right way to fix that.
https://www.drupal.org/comment/9085183#comment-9085183 - the second condition (!isset) is wrong! Don't use it!
https://www.drupal.org/node/2123315#comment-9460235 is correct one and solves all current and future issues with pager in this case.
Comment #83
murzConfirm that patch from #6 solves the problem for me at now. Patch from #2123315 is more complex, I will test and review it.
Comment #84
pcorbett commented#6 works well for me. Patch from #2123315 doesn't work for subsequent pages (if you click on page 2, it returns no records at all and the pager disappears). This is supported by @Murz https://www.drupal.org/node/2123315#comment-9503897
Comment #85
vikramy commentedCan you try patch posted here
Comment #86
rar commentedVikramy, I can confirm that as per your comment #85 ( https://www.drupal.org/node/2123315#comment-9549759 ) that removing content of the function "post_execute" solves this issue for me using views_php 7.x-1.0-alpha1
Comment #87
caspervoogt commented#6 works for me. Tested also with Views Infinite Scroll.
Comment #88
dc_marc commentedIf you want to avoid the patch in order to get your code out of Views PHP (so it can be tracked, versioned, easier to debug, et al), you can use Views' pre-render hook. That worked for me since I wanted pagination but also am part of a complex enough ecosystem of developers that anything I can version control, must be. Hope this helps someone!
Marc
Comment #89
durgeshs commentedI have faced same issue after upgraded views from version 3.7 to version 3.10.
#6 work for me.
Comment #90
durgeshs commentedI have faced same issue after upgraded views from version 3.7 to version 3.10.
#6 work for me.
Thanks
Comment #91
peterlolty commented(deprecated)
Comment #92
peterlolty commented(deprecated)
Comment #93
peterlolty commented(deprecated)
Comment #94
peterlolty commented(deprecated)
Comment #95
peterlolty commentedPlease refer to https://www.drupal.org/node/2123315#comment-9650151
The concept of patches in this post (started from #1, til the end) is not correct, the above link shows the correct one.
Comment #96
peterlolty commentedComment #97
rcodina@peterlolty Always provide a patch, not just a zip file.
Patch on #6 works for many people so I show it again.
Comment #98
rcodina@peterlolty Could you explain in this issue why do you consider this is a duplicate?
Comment #99
peterlolty commented@rcodina
patch#6 is just a workaround because it overrides the query, and force the query function always retrieve up to 666666 records for each query.
Let me explain why,
The 'views_php' using 'wrapper' to wrap the 'views' pager function, it contains two part of code when wrapping the pager function.
1. wrap the pre_query() and post_query() to let the 'PHP filter' code execute.
2. emulate pager function in post_query().
Unfortunately, the pager function in views_php is not necessary started from views_7.x-3.8.
In simple words, the pager function in views_php is duplicated with views_7.x-3.8 (or later) and leads the following problem:
1. breaks the pager function (because both pager function in views and views_php will run one followed by one.)
2. other modules deal with the query and/or results cannot works with views_php properly. (because the query results has been trim off by the views_php pager function.)
Thus, that's why I marked this topic is duplicated and hide the patch#6
Comment #100
peterlolty commentedIn addition, patch#6 breaks the views_navigation.
Comment #101
rcodina@peterlolty Ok, thanks for this explanation.
Comment #102
ssoulless commentedHi I do not understand why you closed this thread, and why a file is a solution instead of a patch, is any patch committed that fixes this issue? because it seems that anything has been committed yet so I open again this thread
Comment #103
peterlolty commentedThe problems came from the same reason stated in the other post. Thus, this is duplicated.
Comment #104
peterlolty commented#102
I did spend several hours to solve this issues (in both posts), and I knew it is hard to understand. I suggest you going to #2123315: Paging vs. Value Field when Integrating with Search API and download patch #69.
Comment #105
crystaldawn commented#104 is correct. I noted the same issue in #27 about a year ago. The patch in #6 should never be accepted as "the fix" since its extremely hackish and restrictive. The patches in issue #2123315 make far more sense as they do not suffer from limitations.
Comment #106
pradeepjha commented#1 works for me.
Comment #107
talisa1987 commented#1 Works for me.
Thanks!
Comment #108
eyjolfur12 commentedJust if it would help someone, since I have been working this, the last few day.
#6, or #1 were not acceptable for our site, since the "limit 666666" generates in our case, slow queries (>3 sec) with large results sets, (in some cases > 100 k), and the reason I started looking into this was to trace slow queries, that were bogging our SQL server down. It should though also be noted, that if you use those patches, you can comment out the line
from execute_count_query(), since the lines
gets the same results. The patch https://www.drupal.org/files/issues/views_php-paging-2123315-86.patch worked better, query wise, but then you need also the count query, that are also slow for any slow query.
Since we do not use standard pagers on our site, only the pagers from the modules "infinit scroll" and "load more", to get the minimum of heavy queries, my version of view_php_plugin_pager.inc, now runs like this:
I.e. telling the pager that it has a large number of pages, but effectively removing the pager, when the query result items are less than "items per page".
Comment #109
sgp913 commentedHi all,
Check out https://www.drupal.org/node/2484407
The patches here all made my server hit 100% CPU immediately. The issue I posted here seems to have resolved this issue.
Comment #110
durgeshs commentedComment #111
bkat commentedHas anyone tried the patch I posted at https://www.drupal.org/node/2484407 with 7,x-1.x? I'm on 7.x-2.x and the patches in this thread did not work for me on 7.x-2.x. It has been suggested that I repost my patch here but I'm hesitant to post anything that I've not tested on this branch.
Comment #112
mummybot commentedApplying the patch referenced in #48 fixed my problem, and addressed the performance/hackyness issues of the patches in #1 and #6.
Comment #113
BOGUƎ commentedI'm with mummybot: applying the patch referenced in #48 also fixed my problem.
Comment #114
pawel_r commentedAlso confirm that #48 resolved missing pager issue (#48 points to patch in #26 of related issue)
Comment #115
nehapandya55 commentedThanks #1 worked for me.
Comment #116
mustanggb commentedWhy would you use the bodge hackaround in #1 as the first thing you found instead of using a real fix as is being worked on over in #2123315: Pager does not appear if fields use Views PHP (7.x-1.x)?
Comment #117
ehsankhfr commented#1 Worked for me.
Thanks!
Comment #118
ehsankhfr commentedMustangGB
Thanks for sharing the link. You're right! The solutions here can work probably in small projects.
I used #69 in #2123315: Pager does not appear if fields use Views PHP and it is working great!
Comment #119
SeanA commentedComment #120
NirmalaGuru commentedThanks.. saved my time...
Comment #121
wesleymusgrove commentedArbitrarily limiting the results to the first 666,666 starts to become a massive performance issue, especially if you're dealing with pagination on a Drupal Commerce BackOffice Orders view with over 5,000 orders. Fatal PHP memory errors start to happen.
https://www.drupal.org/node/1937364#comment-8223543 fixed it for me!
Comment #122
subhojit sinha commented#1 worked for me too
Comment #123
manuel_mra commentedIt worked for me
Thank you very much
Comment #124
phuocdv commented#1 work for me . thanks