This is related to this CCK patch / feature request - an attempt to bring full filter definition settings to CCK fields.
Views.module built-in filter handlers, such as views_handler_filter_like or views_handler_filter_timestamp, (maybe some others ?) do not seem to cope well with the aliases CCK views tables use for the fields names, resulting in the proper tables not being joined.
The current patch makes the two filter handlers mentioned above use $filterinfo['table'] (insetad of only $filter['field']) to ensure the field's table presence.
It's been tested to work for views_handler_filter_timestamp (untested for views_handler_filter_like), but I couldn't say for sure it doesn't break other uses of these handlers outside CCK...
BTW, It would be great If merlin or another cck-aware views guru (or the other way around ?) could review the cck patch mentioned above :-)
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | views_filters.patch | 1.6 KB | yched |
| #4 | views.module4.patch | 2.78 KB | yched |
| views.module_12.patch | 973 bytes | yched |
Comments
Comment #1
magnestyuk commentedyched, the patch doesn't work for views_handler_filter_like.
Comment #2
yched commentedOh, bugger.
Well, I'll look into that tomorrow - sleeping time in Europe :-)
Comment #3
magnestyuk commented(cleared cache--does not work)
Europe is where I am as well :) but I have the nasty habit of working at night...
thanks in advance.
Comment #4
yched commentedOK, I finally was able ta spend some time on that.
This new patch modifies views_handler_filter_like and views_handler_filter_timestamp so that they take into account the 'field' parameter (if any) that was set in the filter definition (in hook_views_tables), so that cck fields can also use these filter handlers.
It has been tested to work with cck-defined filters, as well as with the filters that currently use these handlers (node.title, node.created...)
You might need to :
- empty your cache
- AND re-save your view
for the changes to be taken into account in the generated db queries.
Note : The patch mainly consists in a piece of code that gets repeated in views_handler_filter_like and views_handler_filter_timestamp.
This probably means that it should be factorized elsewhere, before the filter handlers get called, but this would bring me too deep in views.module inner structures, which I don't know too well.
Merlin would probably know of a better way - I'm merely pointing the issue, and proposing a (maybe sub-optimal) fix.
In other words : merlin, please review ! :-)
Comment #5
merlinofchaos commentedYes, I agree that could be generalized. I probably should, but I have 99 open issues and limited time to try and get through them, so I am simply committing for now.
Comment #6
yched commentedMerlin, you committed the wrong patch :-)
The one in comment#4 is The One...
Comment #7
merlinofchaos commentedYikes.
Hopefully I did that right. I had to do the first half of the patch by hand.
Comment #8
merlinofchaos commentedComment #9
yched commentedReopening just to post a cleaner version (the "factorization" thing) :
The correct field is stored inside $filterinfo in the filters building loop, so that the filter handlers functions don't have to bother about it.
Comment #10
merlinofchaos commentedThis works? I didn't think $filterinfo could be written to at that point.
Comment #11
yched commentedYes, it does work.
Just before (*) $filterinfo is passed to the filter handler function, we ensure it contains the right value for 'field', so the handler gets it right. This happens outside the handler instead of inside, that's all...
(*) well, not exactly 'just' before, but that makes no difference.
Comment #12
kindafun commentedI downloaded the latest 4.7 version that I believe now has this patch in it. I created a simple view but got this when trying to view it:
* user warning: Table 'okeefe.node_field_imagefield_data' doesn't exist query: SELECT count(node.nid) FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid LEFT JOIN node_content_property node_data_field_living_area ON node.vid = node_data_field_living_area.vid LEFT JOIN node_field_imagefield_data node_field_imagefield_data_field_bedrooms ON node.vid = node_field_imagefield_data_field_bedrooms.vid AND node_field_imagefield_data_field_bedrooms.field_name = 'field_bedrooms' WHERE (term_node.tid IN ('4')) in /dev/includes/database.mysql.inc on line 120.
* user warning: Table 'okeefe.node_field_imagefield_data' doesn't exist query: SELECT node.nid, node_data_field_living_area.field_living_area_value AS node_data_field_living_area_field_living_area_value, node_field_imagefield_data_field_bedrooms.field_fid AS node_field_imagefield_data_field_bedrooms_field_fid FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid LEFT JOIN node_content_property node_data_field_living_area ON node.vid = node_data_field_living_area.vid LEFT JOIN node_field_imagefield_data node_field_imagefield_data_field_bedrooms ON node.vid = node_field_imagefield_data_field_bedrooms.vid AND node_field_imagefield_data_field_bedrooms.field_name = 'field_bedrooms' WHERE (term_node.tid IN ('4')) ORDER BY node_data_field_living_area.field_living_area_value ASC LIMIT 0, 25 in /dev/includes/database.mysql.inc on line 120.
It looks like it's not getting the table names right, any ideas?
Comment #13
kindafun commentedI have a new version of imagefield.module. Turns out that in function imagefield_views_tables() the instances of:
node_field_imagefield_data
must be changed to:
node_data_field
That took care of the problem, so, it wasn't really a Views problem but rather an imagefield problem.
Comment #14
RayZ commentedComment #15
yched commentedJust to make things clearer.
There is no bug anymore. Everything works smooth.
This patch (in comment #9) just proposes a cleaner implementation, by having the 'field' param ready so that it doesn't have to be figured out by each filter handler separately - and avoid future "improper" filter handlers, e.g. in contribs...
The patch still applies, BTW :-)
Comment #16
RayZ commented@yched, Explanation of a minor detail ... I switched this issue from 4.7.0 to cvs because I don't think Views has been branched for 4.7 yet. (Or more correctly, I think it was branched involuntarily at one point and merlinofchaos had to "un-branch" it).
Comment #17
yched commented@RayZ : I guess you're right. There is a recent 4.7 tag, though...
Well, switching back to 'cvs' :-)
Patch in comment #9 still applies to 4.7 or HEAD, anyhow.
Comment #18
merlinofchaos commentedOkee dokee!
Comment #19
(not verified) commented