public static function disconnectDatabase() { if (isset(self::$db)) { self::$db->disconnect(); self::$db = null; } }
/** * test that the profiler is disabled (mandatory on a production server) */ public function test_profilingDisabledInProduction() { require_once 'Tracker/Db.php'; $this->assertTrue(Piwik_Tracker_Db::isProfilingEnabled() === false, 'SQL profiler should be disabled in production! See Piwik_Tracker_Db::$profiling'); }
define('PIWIK_INCLUDE_PATH', dirname(__FILE__)); @ignore_user_abort(true); if (@(include "Version.php") === false || !class_exists('Piwik_Version')) { set_include_path(PIWIK_INCLUDE_PATH . '/core' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/libs' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/plugins' . PATH_SEPARATOR . get_include_path()); } require_once "Common.php"; require_once "PluginsManager.php"; require_once "Tracker.php"; require_once "Tracker/Config.php"; require_once "Tracker/Action.php"; require_once "Cookie.php"; require_once "Tracker/Db.php"; require_once "Tracker/Visit.php"; require_once "Tracker/GoalManager.php"; session_cache_limiter('nocache'); ob_start(); if ($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) { date_default_timezone_set(date_default_timezone_get()); require_once "core/ErrorHandler.php"; require_once "core/ExceptionHandler.php"; set_error_handler('Piwik_ErrorHandler'); set_exception_handler('Piwik_ExceptionHandler'); printDebug($_GET); Piwik_Tracker_Db::enableProfiling(); Piwik::createConfigObject(); Piwik::createLogObject(); } $process = new Piwik_Tracker(); $process->main(); ob_end_flush(); printDebug($_COOKIE);
/** * Call this method to disable the SQL query profiler */ public function disableProfiler() { $this->profiling = false; Piwik_Tracker_Db::disableProfiling(); }
/** * When destroyed, if SQL profiled enabled, logs the SQL profiling information */ public function recordProfiling() { if(is_null($this->connection)) { return; } // turn off the profiler so we don't profile the following queries self::$profiling = false; foreach($this->queriesProfiling as $query => $info) { $time = $info['sum_time_ms']; $count = $info['count']; $queryProfiling = "INSERT INTO ".Piwik_Common::prefixTable('log_profiling')." (query,count,sum_time_ms) VALUES (?,$count,$time) ON DUPLICATE KEY UPDATE count=count+$count,sum_time_ms=sum_time_ms+$time"; $this->query($queryProfiling,array($query)); } // turn back on profiling self::$profiling = true; }
/** * When destroyed, if SQL profiled enabled, logs the SQL profiling information */ public function recordProfiling() { if (is_null($this->connection)) { return; } // turn off the profiler so we don't profile the following queries self::$profiling = false; foreach ($this->queriesProfiling as $query => $info) { $time = round($info['sum_time_ms']); $count = $info['count']; try { $queryProfiling = "UPDATE " . Piwik_Common::prefixTable('log_profiling') . "\n\t\t\t\t\t\tSET count=count+?, sum_time_ms=sum_time_ms+?\n\t\t\t\t\t\tWHERE query=?"; $this->query($queryProfiling, array($count, $time, $query)); } catch (Exception $e) { $queryProfiling = "INSERT INTO " . Piwik_Common::prefixTable('log_profiling') . "\n\t\t\t\t\t\t\t(count,sum_time_ms,query) VALUES (?,?,?)"; $this->query($queryProfiling, array($count, $time, $query)); } } // turn back on profiling self::$profiling = true; }