Closed (fixed)
Project:
Search API sorts
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Aug 2012 at 19:11 UTC
Updated:
6 Oct 2012 at 16:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commented$_REQUEST returns the same thing as $_GET/$_POST?
I'm thinking of doing something like this (first checking if facetapi_pretty_pahts is installed):
I'll work on a patch today.
Comment #2
Island Usurper commentedI should have been clearer. $_REQUEST['q'] and $_GET['q'] are no longer the same by the time facetapi_pretty_paths does its thing. See the end of FacetapiUrlProcessorPrettyPaths::fetchParams()
I don't know. This might be a bug in facetapi_pretty_paths. I'm not sure why those lines were added.
Comment #3
Anonymous (not verified) commentedNo that's not a bug in FacetAPI, because Search API still works with the original ?f[0] type of filters in the $_GET. So FacetAPi translates the path back to its filters params.
But OK now I like the $_REQUEST solution, will work with that. Thanks for the hint.
Comment #4
Anonymous (not verified) commentedOk, applied your patch to dev-x.
http://drupalcode.org/project/search_api_sorts.git/commit/19f1b53
Comment #5
Anonymous (not verified) commentedI was just testing, and it's actually not a good idea to use $_REQUEST. On my search page /search, $_GET['q'] = search, but $_REQUEST['q'] is just empty. So this is a really bad idea. Working on a better patch to revert the mistake.
Comment #6
Anonymous (not verified) commentedFor some quirky reason, $_REQUEST can be empty on default PHP installation, so I would not use it in Drupal code:
http://stackoverflow.com/questions/5701588/why-is-request-empty
Comment #7
Anonymous (not verified) commentedCommitted a fix to dev-x.
Comment #9
dydave commentedHi guys,
I have been testing the latest dev and updated, particularly the commits: 08c2c8e and 19f1b53 (August 22, 2012) and I encountered a few issues.
(1)Firstly when working on my localhost, I have a base_path which is most likely longer than on production:
http://localhost/mysite1
instead of http://mysite1.com , which I would assume most likely works fine.
So I'm thinking perhaps the base_path should be stripped off from the request_uri call (supposed to return $path).
(2)Secondly, related with ticket:
http://drupal.org/node/1764886
with language prefix there is also a problem: prefix is doubled in URL and the patch submitted on ticket probably needs more work since as noted by morningtime in note#3 there are issues caused by the call to current_path()). Besides, overriding the $path with current_path in the theme function kind of defeats the purpose of the latest commits (see August 22 2012).
One solution to that could be to strip off the language prefix from the request_uri/$path, as in the first point.
(3)Lastly, it seems that when Facetapi Pretty Paths is not enabled, the search arguments f[0], etc... are encoded in the fragment: ?f[0]=....
localhost/mysite/en/views1?f[0]=field1:182
When Facetapi Pretty Paths *is* enabled the path then becomes something like:
localhost/mysite/en/views1/field1/182
and the fragment ?f[0]=field1:182 is not needed anymore
The bug I encountered is that after enabling Facetapi Pretty Paths, the path of the links created on the sort links are a combination of both:
localhost/mysite/en/views1/field1/182?sort=created&order=desc&f[0]=field1:182
the problem is that the f[0]=... shouldn't be there, since it's already passed in the pretty path.
I have tried looking around and see if I could find any work around or solution, but so far, I haven't been able to find any good solution to that last point.
For the first 2, I found myself adding call to str_replace, which seems to work, but I didn't have enough time yet to find any potential solution for 3.
Feel free to let me know if you have any ideas how this feature could be fixed, since I think it would be great to have compatibility with Facetapi Pretty Paths.
I'm looking forward to getting your feedback and comments.
Thanks in advance.
Comment #10
Anonymous (not verified) commentedWhat we need, is a function from FacetAPI Pretty Paths to deliver the actual unaltered $_GET['q']. Would that solve all problems? I tried this:
http://drupal.org/node/1661552#comment-6451890 but even that fails to deliver correctly.
Comment #11
dydave commentedHi morningtime,
I'm glad to be able to follow up on this ticket and thanks again for all your help and feedback in the facetapi_pretty_paths tracker:
http://drupal.org/node/1661552
As you may have noticed, I would like to help you move forward on this, therefore, I have done a little bit of work here that I hope will simplify your task.
Pretty much, below, I'm applying the fixes to the latest dev: 7.x-1.2+4-dev.
Alright, following up with the post, you'll find attached an attempt (File named: sort_pretty_paths-11.patch) to tackle this issue for good with the method you suggested earlier (see above).
From what I saw, there are 2 cases, either facetapi_pretty_paths is enabled or it's not.
In case it's not, I thought we could align the module's $path (line 174 .module file) on the latest change from search_api in the facet adapter:
http://drupalcode.org/project/search_api.git/blobdiff/589b8a01c70534ca24...
In case it is, then, we've got the code from: facetapi_pretty_paths
Hi morningtime,
I'm glad to be able to follow up on this ticket and thanks again for all your help and feedback in the facetapi_pretty_paths tracker:
http://drupal.org/node/1661552
Pretty much, below, I'm applying the fixes to the latest dev: 7.x-1.2+4-dev.
Alright, following up with the post, you'll find attached an attempt to tackle this issue for good with the method you suggested earlier (see above).
From what I saw, there are 2 cases, either facetapi_pretty_paths is enabled or it's not.
In case it's not, I thought we could align the module's $path (line 174 .module file) on the latest change from search_api in the facet adapter:
http://drupalcode.org/project/search_api.git/blobdiff/589b8a01c70534ca24...
In case it is, then, we've got the code from: facetapi_pretty_paths to retrieve the path.
Could you please help me test this patch guys?
I have already tested all these cases, with/without language prefix, with/without folder on localhost or on other types of dev environments, it really seems like everything is now in order.
But I would really be glad to hear your feedbacks after testing and double checking.
Also, I have the feeling the line:
$adapter = facetapi_adapter_load('search_api@'.$index['id']);
could be even further improved, since I got the 'search_api@' part hard coded in there, but I haven't really looked at how this could potentially be obtained dynamically with a function, for example, if there is any at all.
I would really greatly appreciate your feedback on this, and ideally, a module roll out, so that we're able to move forward smoothly and safely with this issue.
Thanks in advance for your help, feedback and advice, really highly appreciated.
Comment #12
dydave commentedI always forget to update the status ....
Comment #13
Anonymous (not verified) commentedSeems OK and working for me. Maybe someone else can confirm before committing?
Comment #14
dasjolooks good to me - i'm happy you folks are getting along with this solution!
just wanted to mention that you should stick to the coding standards for future patches, see http://drupal.org/coding-standards
there is a great tool for reviewing patches and more: http://drupal.org/project/dreditor
Comment #15
dydave commentedOnce again, thank you so much for your valuable input, dasjo.
We're also glad to see this module working now with the facet pretty paths module, which features are very interesting as well.
I have installed/configured dreditor and now I have a new tab on the patch files in the tracker when browsing with Chrome:
Review
It's really cool and at the same time I refreshed a bit my memory on coding standards.
Please find attached a slightly cleaner patch according to coding standards (indentation, whitespace at end of line, etc...).
[File named: sort_pretty_paths-15.patch]
Feel free to let me know guys is there would be anything else to do with this patch/ticket, I would be glad to revise the patch again.
Otherwise, it would be great to see this in the dev version soon.
Thanks in advance!
Comment #16
Anonymous (not verified) commentedCommitted to devx!
http://drupalcode.org/project/search_api_sorts.git/commit/a4de5a1