Closed (fixed)
Project:
Boost
Version:
6.x-1.16
Component:
Views
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Nov 2009 at 12:53 UTC
Updated:
17 Dec 2009 at 05:20 UTC
Jump to comment: Most recent file
Hi, when using Views exposed filters with multiple values per filter the $_GET variables are submitted as an array, like ?var[]=value1&var[]=value2.
This results in $GET['var'] to be an array.
The stored static cache item contains "Array" in the filename, and is never served.
Real example:
?maat[]=219&maat[]=220
results in:
_maat=Array.html
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | boost-637212.patch | 4.03 KB | mikeytown2 |
Comments
Comment #1
mikeytown2 commentedQuick fix is to turn off "Only allow ASCII characters in path". I'll be looking for a proper fix soon.
Comment #2
mikeytown2 commentedabove comment is false. Root of the issue has to do with multi dimensional arrays in the $GET php variable. Here is the problem code
$GET structure for
specials?page=1&field_type_value[0]=3&specials?page=1&field_type_value[]=3I'll be searching for code that reverses this; reproduce the URL given the $GET variable. I would rather not use $_SERVER['REQUEST_URI']; but I might have to. Looks like I need to have 2 sets of URLs as well, [0] & []
Comment #3
mikeytown2 commentedhttp://php.net/http-build-query PHP 5 Function with it's PHP 4 backwards compatibility function
From this I need to do a http://php.net/urldecode on the string; and then deal with [] and [0]; [] [] and [0] [1]
Comment #4
mikeytown2 commentedOpened up an issue in views for the duplicate URL issue
#637900: More consistent looking URL's when submitting exposed filter
Comment #5
keesje commentedThanks for diving in to this so fast.
This is not gonna be fixed in Views, these URL types are common practice.
Proposed solution:
Is there a way to replace these [] chars with e.g. _?
This can be done for the static cache filename easy, but can this be done in .htaccess? (not my cup of tea). I think it is, because ? chars seem to be replaced this way already.
Example:
?maat[]=219&maat[]=220
results in:
_maat__=219&maat__=220
(don't know about & char for sure)
Comment #6
mikeytown2 commented[] are valid character names so why would I replace them with _? That would create a huge headache in htaccess. Long story short, I need to cache these 2 different files, one with [] the other with [0]; which brings the total number of files created with one action up to a potential 8 files... kinda nuts but necessary. This will take some thinking on how to do this correctly. I've started to implement the framework for this since boost can create up to 4 files for each cache action already, using this function
Comment #7
mikeytown2 commentedI should always have the number in the brackets [0] and then use the boost_get_all_filenames() function to strip all numbers out of []. This means I can not use $_SERVER['REQUEST_URI'] and must use something like http_build_query()
Comment #8
keesje commentedYou are right, replacing doesn't solve a thing, strange thinking.
Isn't it possible to just explode the array (if any) for creating the filename to replicate the URL .htaccess looks for? I understand you cant ever figure out if the array keys where in the URL or not once you read the $_GET variable. Can't this information be taken straight from the URL? Like if(stristr($url, '[]')){$containskeys=FALSE;}else{$containskeys=TRUE;}
Maybe this is too simple.
Comment #9
mikeytown2 commentedPlan:
Copy $GET to $query
remove q & destination from $query
run $query through http_build_query()
run that through urldecode()
this is the filename I save in the database
boost_get_all_filenames() will remove all [n] and replace with [] as a variant of the filename - will probably have to use regex to do this.
http_build_query() explodes the array for me, using built in php functions rather then my own.
Comment #10
mikeytown2 commentedComment #11
mikeytown2 commentedcommitted
Comment #12
keesje commentedFix confirmed as working.
Thanks a lot for this amazing fast action!
Comment #13
keesje commentedJust want to add a note:
When using exposed views this way, combined with pagination,this might result in duplicate caching for the first pagination page. This is because the resulting URLs from filter form submission does not contain numeric keys, the pagination URLs do.
This might be browser related too, although I did not encounter, there might be (exotic) browsers that insert these keys when building this type of URL.
Comment #14
mikeytown2 commented@kees
I already took care of that, each page that contains a [0] will also get a page that has [], at the same time. One action will generate 2 files. As merlinofchaos stated, it's a browser issue.
Comment #15
keesje commentedI saw that, great.
Thanks again.
Comment #16
keesje commentedMaybe for another FR issue, I have a case where the duplicate filenames would be unnecessary, because the filter is rendered as HTML links, never containing the browser specific keyless [] arrays.
Is it an option to prevent Boost from saving this file twice?
Comment #17
mikeytown2 commentedIs there a reason why saving the link twice would cause any harm?
Comment #18
keesje commentedThe only reason would be performance. Since filters can produce a lot of URLs (filter argument combinations), this can result in a lot of files. So, if this can be reduced with 50% this might be a slight performance enhancement when generating static cache.
(I have no clue how much effort it takes to write 2 files or 1 to the filesystem, so this is based on gutfeeling, not knowledge.)
Comment #19
mikeytown2 commentedif "Asynchronous Operation: output HTML, close connection, then store static file" is enabled then the performance impact should be minimal. My guess is that the worse case, is an extra 20ms added due to this extra file being written; something I'm not too worried about since its a one time occurrence; a cache miss is generally more expensive then writing an extra file.
Comment #20
keesje commentedThanks for explaining, its not worth the effort then.