xBugEvents.plugin.php 598 B

123456789101112131415
  1. <?php
  2. if ($modx->context->key != 'mgr') {
  3. if ($modx->event->name == 'OnWebPageComplete') {
  4. $modx->query('SET PROFILING = 0');
  5. $modx->query('SET SESSION query_cache_type = ON');
  6. $profiles = $modx->query('SHOW profiles')->fetchAll(PDO::FETCH_ASSOC);
  7. foreach($profiles as $profile) {
  8. $modx->xbugprofiler->addLogEvent('profiles', array('id' => $profile['Query_ID'], 'duration' => $profile['Duration'], 'sql' => $profile['Query']));
  9. }
  10. if ($modx->xbugprofiler) {
  11. $modx->xbugprofiler->writeLog();
  12. }
  13. }
  14. return '';
  15. }