Created
May 10, 2017 17:03
-
-
Save KeyboardCowboy/78a0c6def01f666c5f55d33712171e20 to your computer and use it in GitHub Desktop.
Debug EntityFieldQueries in Drupal 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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