Hi,
with the last 7.x-3.x-dev branch, i have a notice in the get_render_tokens method of views_handler_field object :
Notice: Array to string conversion in views_handler_field->get_render_tokens() (line 1381 of /var/www/vivien/htdocs/drupal-7.14/profiles/nvision/modules/contrib/views/handlers/views_handler_field.inc).
There's in this part of code :
foreach ($_GET as $param => $val) {
if (is_array($val)) {
$val = implode(', ', $val);
}
$tokens['%' . $param] = strip_tags(decode_entities($val));
}
The reason is simple : maybe the $val var contains an array to. For exemple, in the date module, the $val is something like :
$val['value']['year'] = '2012'.
2 solutions i think :
- force others modules to cleanup $_GEt parameters before sending it to the browser
- allow views tokens to manage this kind of parameters
The second solution is the best of course :), Coders could have more flexibility.
A recursive implode could be a solution.
Thx.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 1566770-12.patch | 2.97 KB | damiankloip |
| #11 | 1566770-11.patch | 3 KB | damiankloip |
| #10 | 1566770-10.patch | 3.07 KB | damiankloip |
| #8 | 1566770-8.patch | 1.91 KB | damiankloip |
| #7 | 1566770-7.patch | 846 bytes | damiankloip |
Comments
Comment #1
dawehnerWhat about just another level of hierarchy? This would be somehow easy to do but you know recursive should work as well.
Your first suggestion would probably be too hard, as this requires people to change fapi-structure which is hard.
Comment #2
VivienLetang commentedYes, the simple way is to add another level. I will suggest a patch soon.
Thx for the reply
Comment #3
damiankloip commentedWe could use some SPL iterators to deal with this, then it doesn't matter how deep the nesting is in the query string. It keeps it nice and clean too. Patch attached.
Comment #4
BeaPower commentedGetting this error too, has a fix been committed?
Comment #5
dawehner@Beapower: If it would be committed, the status wouldn't be "needs review" anymore, simple :)
The code itself is nice, at least some structures of php are actually nice ...
About the actual fix, shouldn't sub-elements have a different key to access them?
Comment #6
damiankloip commentedWe could easily get the depth of the element key returned and use that? or do you want something that appends the keys together instead?
Comment #7
damiankloip commentedSomething more like this maybe?
Comment #8
damiankloip commentedHere is a new idea, this is actually much better. So it will iterate recursively over the query array and create a nested token structure. So a query string like this :
....?param[foo][a]=test¶m[bar][a]=test¶m[foo][bar][a]=testWill create the following set of tokens:
At the moment the patch uses a function inside the method, so then it can call this recursively, plus it's only being used there. Do you think it would be better if this just used it's own method instead? Incase it needs to be used somewhere else again (you never know)?
Comment #10
damiankloip commentedSorry, that just wouldn't work like that. Here is a proper version, creating a get_token_values_recursive method instead. Complete with comments etc...
Should there maybe be another parameter in this method to choose the token prefix? incase it needs to be used elsewhere ever. i.e. % or ! etc...
Comment #11
damiankloip commentedor we just ditch the RecursiveArrayIterator, probably not much point if we use a function to get the tokens now!
Comment #12
damiankloip commentedHere is an updated version with the right docblock text.
Comment #13
dawehnerLooks perfect now!
Comment #14
dawehnerThanks for the work, committed to 7.x-3.x and 8.x-3.x
Comment #15
VivienLetang commentedNice work. Thx to all
Comment #16
KingSalibah commentedPatch worked for me!
Comment #17.0
(not verified) commentedcode tag