Problem/Motivation

If you subclass the views_plugin_query_default class, then the query arguments will not be substituted in the query string displayed in views preview. In views_ui_preview(), the relevant condition is:
if (get_class($view->query) == 'views_plugin_query_default')
which does not allow for a subclass.

Proposed resolution

Change the above condition to allow for subclasses.

Remaining tasks

Review, test. (Do we need a test of this change with a subclass?)

User interface changes

Preview query will include argument substitution.

API changes

None.

Comments

solotandem’s picture

Status: Active » Needs review
StatusFileSize
new963 bytes

Attached patch implements proposed resolution.

I question whether the condition should be simply:
if (method_exists($query, 'getArguments'))
given the comment
Only the sql default class has a method getArguments
that precedes this block.

chris matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 4 year old patch to admin.inc does not apply to the latest views 7.x-3.x-dev and if still relevant needs to be rerolled.

Checking patch includes/admin.inc...
error: while searching for:
          // Only the sql default class has a method getArguments.
          $quoted = array();

          if (get_class($view->query) == 'views_plugin_query_default') {
            $quoted = $query->getArguments();
            $connection = Database::getConnection();
            foreach ($quoted as $key => $val) {

error: patch failed: includes/admin.inc:190
error: includes/admin.inc: patch does not apply
andrew answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new961 bytes

Patch rerolled.

anrikun’s picture

Category: Feature request » Bug report
Status: Needs review » Reviewed & tested by the community

This is a bug for me.
Patch works.

renatog’s picture

I agree to use instanceof instead of get_class since that get_class will compares the name of the class. I think instanceof is better and is solving the issue

Good catch! +1 to it as RTBC

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #3232189: Plan for Views 7.x-3.26

Committed. Thank you all.

Status: Fixed » Closed (fixed)

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