Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

The problem with the current patch, the method option_definition has to be fired and the options has to be stored after submit

dawehner’s picture

Just some ideas: Move groupby-settings, distinct ... into the query builder settings. Thats sure not supported by every query builder plugin.

dawehner’s picture

Rerole the patch. No progress else.

seehawk’s picture

Is this issue still a planned part of this patch?

http://drupal.org/node/548104

Thanks!

dawehner’s picture

It is planned, but i don't had time to develop it.... you could help coding it

seehawk’s picture

If I was a better coder, I would. :-) I'll be happy to help test, though!

Scott Reynolds’s picture

Subscribing, Solr Views needs this to go forward here and remove some HEAVILY crufted code. Hoping to come back to this real soon.

YK85’s picture

subscribing

Scott Reynolds’s picture

I took a quick look at this last night and this original patch was going to allow the query plugin to be configurable on a View level not a Display level. I am reworking it for a Display level: http://skitch.com/supermanscott/n43ty/query-builder

Is there a good reason why it wasn't on the display level ?

dawehner’s picture

FileSize
9.93 KB

Oh damn i really missed to upload a recent version

But this does not work

Scott Reynolds’s picture

FileSize
10.54 KB

He is a 'working' patch though it doesn't export properly and I have a couple issues with it.

1.) The options form function has to fetch the plugin and init it. Its really strange, it shouldn't have to do that it should be handled in the views_plugin_display::init()
2.) The option definition is similar to access and cache. And thats probably wrong in this case. And the reason its not exporting properly.
3.) I don't like this wording: "t('Disable node access')". As someone who as written a couple db_rewrite hooks, it isn't always node access. The option should actually say what it does and I further hope that this becomes a Filter in D7 or a separate UI element for query tags.
4.) Distinct and group by should be default query plugin options. While Solr does have a rudimentary group by-like system, its will have distinctly different behaviors and I think that will hold true for other query plugins.
5.) like to move the summary_title() from views_plugin_query_default to views_plugin_query.

I think the big thing to review, is the decision to have the display object init the query as opposed to the View object itself and the ramifications that can hold.

Scott Reynolds’s picture

Status: Needs work » Needs review
FileSize
10.84 KB

Ok here is a working clean patch. It addresses all the points above expect Distinct and group by. First off, group by isn't an issue, there is a whole system around that, views_query::get_aggregation_info() so it is not a worry.

Distinct is a bit of a different beast and that probably is best handled in a separate issue.

Scott Reynolds’s picture

Status: Needs review » Needs work
FileSize
10.51 KB

This is a reroll with a little cleanup. Overriding isn't working.

Scott Reynolds’s picture

It is also not setting the 'options' array based on the $query::option_definition and its not setting the right query type. Probably don't need to maintain the query type as its determined from the base_table anyways.

Here is what the solr form is looking like: http://skitch.com/supermanscott/n5n5i/solr-query-form

Scott Reynolds’s picture

posted a patch for Solr Views #750234: Configurable boosts per View display..

Right now I think the problem resides with how option_definition is called. Sometimes it is called after views_plugin_display::init() and other times it hasn't been. This causes issues with the default value for the query type. So while normal Views are fine, once exported it isn't as the query type has been lost.

The other issue is that the options can't be overridden it seems. I think this is a logical issue not necessarily an architectural issue.

Ideas? Thoughts? Am I way off base?

Scott Reynolds’s picture

Status: Needs work » Needs review
FileSize
11.8 KB

Ok, I got this one. Here is an updated, working patch.

It is also not setting the 'options' array based on the $query::option_definition and its not setting the right query type. Probably don't need to maintain the query type as its determined from the base_table anyways.

Actually had to do this so that way export_plugin could figure out the option_definition(). So i made sure to $display->set_option() that in the views_plugin_display::init. The Solr patch is updated as well.

I believe I got all the ->init_query() calls, but please grep yourself to make sure.

Anonymous’s picture

Status: Needs review » Needs work

For me, the options still can't be overriden in the user interface.

I am using a textfield for inputting a URL, just like Twitter Views does. I try to change the URL from the default and click update, but when I look back the default value is there again.

Anonymous’s picture

Status: Needs work » Needs review

Nevermind, need to add a submit handler.

dawehner’s picture

You shouldn't have to add a submit handler. Can you pastebin your code somewhere?

Anonymous’s picture

Here is the code for the options_defintion and options_form: http://pastebin.com/CC0mbgcV

Anonymous’s picture

dereine, did you try the patch in #16 with Twitter Views? For me, it doesn't work with Twitter Views either. The options box displays in the Views UI, but I can't change it from the default.

Anonymous’s picture

I solved the problem. I wasn't passing $query_options into the init() function in mymodule_plugin_query_sparql.inc.

In case anyone else runs into this problem, this is what I had to do. I am just setting the $this->endpoint_url to the options even if it hasn't been defined yet because I don't have a default value--the user always needs to define their endpoint.

in sparql_views_plugin_query_sparql.inc

  function init($base_table = 'sparql_ep', $base_field, $query_options) {
    $this->endpoint_url = $query_options['endpoint_url'];
    $this->api_method = variable_get('sparql_views_api_method', 'json');
  }
Scott Reynolds’s picture

Ahh this puzzled me for awhile as well. That makes sense, that is the major api change.

It should probably


  /**
   * Constructor; Create the basic query object and fill with default values.
   */
  function init($base_table = 'twitter_api', $base_field, $options) {
    module_load_include('inc', 'twitter');

    $this->options = $options;
  }

And then there is a switch on the api method which should be instead

switch ($this->options['api_method'])

And the url should use the $options array as well.

But it seems that the form work and it saved everything for you and you were able to export it? If so, would you consider it RTBC ?

dawehner’s picture

Can't we just move this to the init method of views_plugin_query and call parent::init in the other init-methods

Scott Reynolds’s picture

Yes, that is what the default plugin does in this patch. Getting bogged down in details for another module, seems like this patch worked though!

Scott Reynolds’s picture

Status: Needs review » Needs work

First, I doubt this applies anymore. Second, it should model view::init_style(), which will delay building the query till its needed.

Thanks for dereine for the review.

dawehner’s picture

Status: Needs work » Needs review
FileSize
10.06 KB

It still applied.

I removed the init_query from display handler initing, this was not nice.

Fixed some more stuff and made init_query clean.

This patch looks now much better for me.

dawehner’s picture

FileSize
11.41 KB

Here is a new version which fixes a notice

dawehner’s picture

FileSize
10.07 KB

Sry this file contained another patch. Here is a new version.

dawehner’s picture

Issue tags: +views 3.x roadmap

This is part of the roadmap for me

dawehner’s picture

Issue tags: +alpha-4 blocker

add tag

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)
FileSize
10.21 KB

Committed to 6.x-3.x!

Doesn't quite apply to 7.x so marking for porting.

I've created http://drupal.org/node/882800 as a followup to move the DISTINCT setting.

dawehner’s picture

FileSize
11.36 KB

I just mentioned that db_rewrite_sql will not work at the moment for d7. Huge performance improvement ;)

OH. I just realized that this patch helps for some of my major performance problems. Subscribing

I love dbtng, i have to underline this again.

As you can read on http://drupal.org/node/310077 node has node_access but terms has term_access. The problem is that i can't find a generic way to add the access tag.
The patch currently uses addTag($this->base_table . '_access'); but this is not working for terms.

What about adding a "access query tag" property in the base table data?

dawehner’s picture

Status: Patch (to be ported) » Needs review
FileSize
13.34 KB

This uses the previous approach

dawehner’s picture

Status: Needs review » Fixed

Cool. There was some minor bugs but now it works fine.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Status: Closed (fixed) » Active

I am unsure of something that was committed in this issue. It seems to have started in the patch posted in #12.

+++ plugins/views_plugin_display.inc	21 Mar 2010 23:15:35 -0000
@@ -404,6 +408,12 @@ class views_plugin_display extends views
+          'options' => array('default' => array(), 'export' => FALSE),

Why is export set to FALSE? If I change this to true, then it seems to work perfectly (I can export and import settings).

Feel free to close this if this is by design.

Anonymous’s picture

To give a little more context, here is the block around that line as it shows up in the last patch.

+++ plugins/views_plugin_display.inc	14 Aug 2010 06:58:06 -0000
@@ -391,6 +393,12 @@ class views_plugin_display extends views
+      'query' => array(
+        'contains' => array(
+          'type' => array('default' => 'views_query', 'export' => 'export_plugin'),
+          'options' => array('default' => array(), 'export' => FALSE),
+         ),
+      ),
Anonymous’s picture

+++ plugins/views_plugin_query_default.inc	14 Aug 2010 06:58:06 -0000
@@ -1086,6 +1111,18 @@ class views_plugin_query_default extends
+    $query->addMetaData('view', $this->view);
+    $count_query->addMetaData('view', $this->view);

Also, I believe that addMetaData is a function only in Drupal 7. I noticed this in alpha3 when I was trying to develop tests because it failed the basicView test.

EDIT: Nevermind, it looks like you caught this in the final commit.

dawehner’s picture

#38
The stuff here is a bug in 6.x-3.x too.

Also, I believe that addMetaData is a function only in Drupal 7.

yes this is part of basicView test in d6?

Anonymous’s picture

FileSize
740 bytes

#38
Ok, I can post it as a new issue if you think that is best. I am attaching a patch that fixes it in this one case, but I haven't looked through to see if there is anything I'm missing. This patch fixes it for me, at least.

#39
I noticed that it was in one of the execute functions in 6.x-3.0-alpha3. But when I downloaded 6.x-3.x-dev, I saw that you had already taken care of it. But then when I saw it in the patch here, I thought that maybe it had been a part of the patch that was committed. After posting, I realized that you had already caught it and that it wasn't in -dev.

dawehner’s picture

I understand now why it does not happen. You don't implement option_definition in your query plugin. :(
See #907400-5: Unable to override Query Settings

mathieu’s picture

subscribing

dawehner’s picture

Status: Active » Fixed

So this is fixed again. *puh*

Status: Fixed » Closed (fixed)
Issue tags: -views 3.x roadmap, -alpha-4 blocker

Automatically closed -- issue fixed for 2 weeks with no activity.