diff options
-rw-r--r-- | core/FrontController.php | 1 | ||||
-rw-r--r-- | core/SettingsPiwik.php | 6 | ||||
-rw-r--r-- | core/Url.php | 10 | ||||
-rw-r--r-- | index.php | 4 | ||||
-rw-r--r-- | misc/cron/archive.php | 8 | ||||
-rw-r--r-- | misc/others/test_generateLotsVisitsWebsites.php | 1 | ||||
-rw-r--r-- | piwik.php | 1 | ||||
-rw-r--r-- | plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php | 6 |
8 files changed, 29 insertions, 8 deletions
diff --git a/core/FrontController.php b/core/FrontController.php index 77e1f73714..de341ec971 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -260,6 +260,7 @@ class FrontController try { Db::createDatabaseObject(); + Piwik_GetOption('TestingIfDatabaseConnectionWorked'); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 51e7c006a8..d615aad7a8 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -175,7 +175,11 @@ class SettingsPiwik */ public static function rewriteTmpPathWithHostname($path) { - $configByHost = Config::getInstance()->getConfigHostnameIfSet(); + try { + $configByHost = Config::getInstance()->getConfigHostnameIfSet(); + } catch(Exception $e) { + // Config file not found + } if(empty($configByHost)) { return $path; } diff --git a/core/Url.php b/core/Url.php index f2cb601d45..ea8e07766e 100644 --- a/core/Url.php +++ b/core/Url.php @@ -268,6 +268,16 @@ class Url } /** + * Sets the host. Useful for CLI scripts, eg. archive.php + * + * @param $host string + */ + static public function setHost($host) + { + $_SERVER['HTTP_HOST'] = $host; + } + + /** * If current URL is "http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2" * will return "example.org" * @@ -40,14 +40,16 @@ require_once PIWIK_INCLUDE_PATH . '/vendor/autoload.php'; require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/core/functions.php'; +define('PIWIK_PRINT_ERROR_BACKTRACE', false); + if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) { require_once PIWIK_INCLUDE_PATH . '/core/Error.php'; Error::setErrorHandler(); - require_once PIWIK_INCLUDE_PATH . '/core/ExceptionHandler.php'; ExceptionHandler::setUp(); } + if (!defined('PIWIK_ENABLE_DISPATCH') || PIWIK_ENABLE_DISPATCH) { $controller = FrontController::getInstance(); $controller->init(); diff --git a/misc/cron/archive.php b/misc/cron/archive.php index e7160ece36..cd1747280e 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -117,12 +117,12 @@ class CronArchive public function init() { + $this->initPiwikHost(); $this->initCore(); $this->initTokenAuth(); $this->initCheckCli(); $this->initLog(); $this->displayHelp(); - $this->initPiwikHost(); $this->initStateFromParameters(); Piwik::setUserIsSuperUser(true); @@ -675,6 +675,7 @@ class CronArchive FrontController::getInstance()->init(); } catch (Exception $e) { echo "ERROR: During Piwik init, Message: " . $e->getMessage(); + //echo $e->getTraceAsString(); exit; } } @@ -831,6 +832,11 @@ class CronArchive $piwikUrl .= '/'; } } + + // HOST is required for the Config object + $parsed = parse_url($piwikUrl); + Url::setHost($parsed['host']); + if (Config::getInstance()->General['force_ssl'] == 1) { $piwikUrl = str_replace('http://', 'https://', $piwikUrl); } diff --git a/misc/others/test_generateLotsVisitsWebsites.php b/misc/others/test_generateLotsVisitsWebsites.php index b9309f50b1..f2a4ba94b0 100644 --- a/misc/others/test_generateLotsVisitsWebsites.php +++ b/misc/others/test_generateLotsVisitsWebsites.php @@ -31,7 +31,6 @@ class Piwik_StressTests_CopyLogs $config = Config::getInstance(); $config->log['log_only_when_debug_parameter'] = 0; $config->log['logger_message'] = array("logger_message" => "screen"); - \Piwik\Log::make(); } function run() @@ -77,7 +77,6 @@ if ($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) { Common::printDebug("Debug enabled - Input parameters: <br/>" . var_export($_GET, true)); \Piwik\Tracker\Db::enableProfiling(); \Piwik\FrontController::createConfigObject(); - \Piwik\Log::make(); } if (!defined('PIWIK_ENABLE_TRACKING') || PIWIK_ENABLE_TRACKING) { diff --git a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php index c57677e3b4..7e8237a6a3 100644 --- a/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php +++ b/plugins/CoreVisualizations/Visualizations/JqplotGraph/Evolution.php @@ -91,9 +91,9 @@ class Evolution extends JqplotGraph $defaultLastN = self::getDefaultLastN($period); $originalDate = Common::getRequestVar('date', 'last' . $defaultLastN, 'string'); - if ($period == 'range') { // show evolution limit if the period is not a range - $view->show_limit_control = false; - } else { + if ($period != 'range') { // show evolution limit if the period is not a range + $view->show_limit_control = true; + // set the evolution_{$period}_last_n query param if (Range::parseDateRange($originalDate)) { // if a multiple period // overwrite last_n param using the date range |