Skip to content

Instantly share code, notes, and snippets.

@KeyboardCowboy
Created May 10, 2017 17:03
Show Gist options
  • Save KeyboardCowboy/78a0c6def01f666c5f55d33712171e20 to your computer and use it in GitHub Desktop.
Save KeyboardCowboy/78a0c6def01f666c5f55d33712171e20 to your computer and use it in GitHub Desktop.
Debug EntityFieldQueries in Drupal 7
<?php
/**
* Implements hook_query_TAG_alter().
*
* Add the tag 'debug' to any EFQ and this will print the query to the messages.
*
* @param \QueryAlterableInterface $query
*/
function MYMODULE_query_debug_alter(QueryAlterableInterface $query) {
if (function_exists('dpq') && !$query->hasTag('debug-semaphore')) {
$query->addTag('debug-semaphore');
dpq($query);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment