0

I am running a D7 site that someone else built and I'm having trouble seeing how an SQL command in a particular view has been altered. In particular, the attributes in the SELECT statement appear to have been altered.

Is there a way to search my database to see if the person building the site added an errant hook_views_query_alter command that is the reason the SQL filter looks different than one would expect just looking at the fields in the View?

Or is there another, better way to debug this issue? Thanks for any help!

1 Answer 1

1

Views field output can also be rewritten under the view's fields setting in the views interface using "rewrite the output of this field" using tokens from previous rows or arbitrary HTML. That's the likeliest place.

If not there, the next candidate for views output modification is in the theme template files. People will stick any kind of logic in views theme template files. To see if custom template files are in use, see "Theme: Information" in the views and the template file in use will be in bold.

Generally, hook_views_query_alter is not the normal way of modifying a view. But a hook_views_query_alter would be added in the code rather than the database. Drupal does cache a list of implemented hook functions in a the theme registry table, but that's not very readable nor informative. Not where you should be looking. Your best bet is to search your code for "_views_query_alter" and see what you turn up. There will be a lot of results, but likely you'll recognize any custom modules.

I might also turn on Show SQL Queries in under Views->Settings to see the output of the views query as views reports it as it's being run in the Views preview interface below the view builder interface. Then you can see the query being run to see if it matches your expectations.

There is also a setting in views under Advanced -> Query to turn off SQL rewriting for a view. This will disable access checks as well as some query rewriting (but not all) so use sparing.

2
  • @Jeremy_John this is helpful - you're right, I think it's in the "rewrite the output of this field" setting in one of the fields. The problem is, there are thirty fields in each of the views I'm looking at. Is there a way to programmatically search this in the database or some other way to search it?
    – YPCrumble
    Jun 22, 2015 at 23:03
  • Inspect the outputted views markup with firebug, the field names will be printed there in the classes. As for searching the database, field settings are in some big serialized array which, if you encountered it, would not be terribly useful. Just click on each of the fields and poke around. You'll notice if "exclude from display" is checked, then that means that field is being printed as a replacement value in a later field. Rows can only replace from those before. So find a later field which does the value printing. And inspect the markup to give you a clue. Jun 23, 2015 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.