Closed (fixed)
Project:
Search API
Version:
7.x-1.x-dev
Component:
Views integration
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Jul 2011 at 11:27 UTC
Updated:
4 Mar 2014 at 09:53 UTC
Jump to comment: Most recent
Comments
Comment #1
drunken monkeyThanks for creating this issue!
Subscribing.
Comment #2
dawehnerTo what kind of pagers do you refer?
Do you refer to views pager plugins? It's a bit hard to understand this issue
Comment #3
merlinofchaos commentedWithout specific questions, all I can really do is show you the code that's used to execute the pre/post execute methods on the pager:
Comment #4
merlinofchaos commentedThe above code is part of views_plugin_query_default::execute()
Comment #5
dawehnerIt could be that they want to move up pager->pre_execute before executing the cout query.
Comment #6
merlinofchaos commentedI don't see what benefit that would provide.
Comment #7
drunken monkeyThis isn't about changing the code in the default query plugin, but understanding what to add for other query plugins.
The problem (according to the OP) seems to be that without calling the pager's
pre_execute()andpost_execute()methods, PHP filters don't seem to work. Currently the Search API doesn't call those, and as the methods take a database query as a parameter (which the Search AP does not use), it seems I also can't do this.Now the question is: Is it really necessary to call the two methods for a correctly working PHP filters, or could something else be the reason? The pager seems to work just fine as it is (as far as I know/can tell). The OP has reported problems in that respect with the Search API Views integration.
Comment #9
dkgof commentedSorry, i have been away on vacation, and therefor not been able to keep up with this issue as much as i should have.
I will try to explain in greater detail.
The problem i am experiencing is that PHP Filter's added to the view to filter search results does not work, even if i add a filter that should filter every result, the search still shows all results on any given query. The reason i believe that the pre_execute() and post_execute() methods are the missing step is that i could get it somewhat working by inserting these. But with my limited understanding of the Search API code and the Views code i never got it working 100%, the search page pager sees all to many pages when my filter removes some of the search results.
The need for the filtering of search results via the PHP Filter is that we have access control on nodes, and not all users are allowed to see all nodes, so they naturally have to be excluded from the results.
Comment #10
dkgof commentedComment #11
drunken monkeyI have thought intensely about entity access checks in the Search API, and I'm pretty sure there is really no way of doing this while still having correct paging. Specifically, if you post-filter the search results with PHP code, it's both clear and inevitable that the paging will be false (as soon as any items get filtered): when you get ten results, and filter out two, there is no way to still display ten results for the page. There is also no (easy) way to tell how many results there will be in total, after they are filtered by your PHP code.
For minimizing the impact of this filtering, try to put as much of the access checks as possible into normal Search API filters. If you want to dynamically filter for the access rights of the current user, you could do this with a query alter hook, dynamically adding the filters necessary for the current user (on status, type, etc.).
Comment #12
drunken monkeySo, is the issue fixed with this information?
Would like to close this issue, as various people seem to have been confused by it.
Comment #14
lex0r commentedSorry to re-open this issue, but I found another use case where we need post_execute() on pager object to be called with view results to allow some post-processing. Namely, there is a module views_load_more that uses post_execute() to do some of its magic. The fix is pretty trivial if you just want to have post_execute called and pager has an implementation of it. I will probably create a patch but for now:
This part does the job:
Comment #15
drunken monkeyYou didn't re-open the issue, you just posted to it which normally no-one would see. Change the status back from "Closed" if you want people to see your comment.
Anyways, this is already fixed in newer versions of the Search API. Just use a recent release, or the newest dev version, and things should work fine.