I'm currently troubleshooting an issue where anonymous users and certain roles see a different set of results from a view than administrators and roles with more permissions do. The view is supposed to have two node results, but for anonymous and others, there is only one.
I am trying to get the full SQL of the final query that's creating the anonymous pages. I'm using
hook_views_query_alter(), and I can get the full query using
dpq($view->query->query()); when I'm logged in as an administrator.
However, when I'm an anonymous user, or one of the other roles encountering the bug, I get SQL like this:
((taxonomy_index.status = :db_condition_placeholder_7) AND (node_field_data.type IN (:db_condition_placeholder_8))).
I tried getting the placeholder values from a technique I used in drupal 7, using the
arguments() method, but apparently that doesn't exist in Drupal 8.
But moreover, I would like to avoid matching up the string
db_condition_placeholder manually, because I could make a mistake, and misdiagnose what the source of the problem is. I want the full query string that drupal sends to the database, so that I can debug it directly with the MySQL server.
I tried other techniques listed here, such as
->addTag('debug'), which apparently did nothing, and
kint($view->query->query());, which only returns output for administrator users.
How can I get the full query string from a view executed for anonymous users?