I have been working on updating my module to work with the latest Views 7.x branch, and have run into an issue.
Basically what is happening is my module is providing a Style plugin that uses the uses fields parameter as FALSE. What happens next is the views module constructs a view query without providing any fields which causes a crash, see the attached views_crash.png image.
After some digging, I think I have come up with a solution to this issue with the patch ( also provided ). Basically what this does is assumes they want all the fields for the base_table if they specify the parameter of "uses fields" as FALSE within their plugin.
I am not sure if this will work for everyone, but for my specific use case ( the MediaFront module ), this works beautifully. See the happy_view.png image attached. :)
I hope this helps.
Travis.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | views-6.x-3.x-uses-fields-857946-10.patch | 797 bytes | travist |
| #10 | views-7.x-3.x-uses-fields-857946-10.patch | 800 bytes | travist |
| #9 | views-7.x-3.x-uses-fields-857946-9.patch | 1.57 KB | travist |
| #9 | views-6.x-3.x-uses-fields-857946-9.patch | 1.43 KB | travist |
| #5 | views-6.x-3.x-uses-fields-857946-5.patch | 1.44 KB | travist |
Comments
Comment #1
travist commentedFYI... I also just checked in the latest changes I made to the MediaFront module to CVS, if you would like to check it out and see for yourself. The CVS tag is DRUPAL-7--1.
Thanks again for your attention to this.
Travis.
Comment #2
dawehnerplease try to use drupal code style. Here it should be if ($uses_fields) {
Powered by Dreditor.
And in general more important, you have to write a patch for 6.x-3.x and 6.x-2.x, too. This might change the logic here. Could you explain it more detailed.
Comment #3
travist commentedHere is the latest patch for Drupal 7.
I don't think that this is even an issue with Drupal 6 since it uses a different database library than Drupal 7. So, I am pretty sure that this is only required for Drupal 7.
Basically the rundown here of what this is doing....
If you provide ANY plugin that specifies that it does not use fields within the plugin declaration, the current implementation will crash since it tries to run a query similar to SELECT FROM {....... The problem here is we are not providing any fields to SELECT. We need to at least say SELECT * FROM {..... if no fields are provided. So, the fix above basically tells the view, that if they do not use fields, to go ahead and grab all fields for the base table in the query.
This works very well for my needs, where I cannot force the user to specify the fields that my widget requires ( a media player ). You see, my media player definitely needs fields within each row to function, but the user would never know which ones since it changes for almost every use case and implementation I can think of. By only returning the fields that they added in the view ( which is what the current implementation of Views for Drupal 7 does ), I have no choice but to declare my widget as one that does not use fields, and then hope that views passes me back ALL fields for the base table. This is what this patch brings to the table.
Let me know if you need any more info.
Thanks for your attention in this matter.
Travis.
Comment #4
dawehnerPlease write patches for 6.x-3.x, and 6.x-2.x, too
Are you really sure that's what you need?
You definitive need a field to be able to do anything, for example a id, like nid.
If you need all fields i would say that this should be the job of the plugin. It can iterate over each definition and add the field, if there is one.
If * would be used, people using this could slow down the database a lot. Let's asume you have multiple joins, then * would return perhaps 30 fields.
Comment #5
travist commentedThis issue has unfortunately come up again, and is keeping adoption of MediaFront 7x from happening for those who are using Views 3x.
Here is the related issue queue item in MediaFront that is caused by this problem. http://drupal.org/node/1059868
Here are patches for both Drupal 6 and 7 that fixes this issue.
Thanks,
Travis.
Comment #6
travist commentedComment #7
travist commentedComment #8
dawehnerPlesae keep the version.
Comment #9
travist commentedHere are the latest patches that use '--no-prefix' so it can be applied relatively. There is a patch for both 6.x-3.x and 7.x-3.x.
Thanks,
Travis.
Comment #10
travist commentedI just found a MUCH more elegant way to do this which is the same between the Drupal 6 and Drupal 7 versions. It is also much more explanatory on what is going on and what I need to have this fixed.
Comment #11
dawehnerDoesn't this code in views_plugin_row already secure this?
You should probably set the base_field in your plugin as row_node_view does it:
Comment #12
travist commentedWell, I think it would, but my widget declares the following...
I don't need a row plugin, so I declared 'uses row plugin' as FALSE. My widget is simply a MediaPlayer style where I take the view results and populate a media player playlist from that view. I didn't see the need for a row plugin since I am passing along all the rows to my widget to render.
And as for your second notion, I am not totally sure that would work in a style plugin. I have always assumed that the style plugins really should not have any control over the query, but maybe that would work. Let me know otherwise.
Thanks for your attention to this.
Travis.
Comment #13
dawehnerAssign to earl for review/comment about the issue itself.
Comment #14
mustanggb commented