Skip to content

Commit

Permalink
Refs matomo-org#4133 Finishing the code changes and build seems to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Sep 30, 2013
1 parent 6b20a98 commit 61b8e59
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions core/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public function init()

try {
Db::createDatabaseObject();
Piwik_GetOption('TestingIfDatabaseConnectionWorked');
} catch (Exception $e) {
if (self::shouldRethrowException()) {
throw $e;
Expand Down
6 changes: 5 additions & 1 deletion core/SettingsPiwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ public static function isUniqueVisitorsEnabled($periodLabel)
*/
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;
}
Expand Down
10 changes: 10 additions & 0 deletions core/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ static public function getHost($checkIfTrusted = true)
return false;
}

/**
* 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&param2=value2"
* will return "example.org"
Expand Down
4 changes: 3 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@
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();
Expand Down
8 changes: 7 additions & 1 deletion misc/cron/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -675,6 +675,7 @@ private function initCore()
FrontController::getInstance()->init();
} catch (Exception $e) {
echo "ERROR: During Piwik init, Message: " . $e->getMessage();
//echo $e->getTraceAsString();
exit;
}
}
Expand Down Expand Up @@ -831,6 +832,11 @@ private function initPiwikHost()
$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);
}
Expand Down
1 change: 0 additions & 1 deletion misc/others/test_generateLotsVisitsWebsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function init()
$config = Config::getInstance();
$config->log['log_only_when_debug_parameter'] = 0;
$config->log['logger_message'] = array("logger_message" => "screen");
\Piwik\Log::make();
}

function run()
Expand Down
1 change: 0 additions & 1 deletion piwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ private function calculateEvolutionDateRange(&$view)
$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
Expand Down

0 comments on commit 61b8e59

Please sign in to comment.