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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | views-enable_argument_substitution_in_preview-2366477-3.patch | 961 bytes | andrew answer |
Comments
Comment #1
solotandem commentedAttached 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 getArgumentsthat precedes this block.
Comment #2
chris matthews commentedThe 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.
Comment #3
andrew answer commentedPatch rerolled.
Comment #4
anrikun commentedThis is a bug for me.
Patch works.
Comment #5
renatog commentedI 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
Comment #7
damienmckennaCommitted. Thank you all.