diff options
-rwxr-xr-x | console | 22 | ||||
-rw-r--r-- | core/Console.php | 2 | ||||
-rw-r--r-- | core/CronArchive.php | 24 | ||||
-rw-r--r-- | core/Url.php | 3 | ||||
m--------- | tests/PHPUnit/UI | 0 |
5 files changed, 30 insertions, 21 deletions
@@ -1,5 +1,6 @@ #!/usr/bin/env php <?php +namespace Piwik; define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__)); define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); @@ -11,17 +12,22 @@ require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -Piwik\Translate::loadEnglishTranslation(); +Translate::loadEnglishTranslation(); -// load active plugins -$pluginsManager = \Piwik\Plugin\Manager::getInstance(); -$pluginsToLoad = \Piwik\Config::getInstance()->Plugins['Plugins']; +if (!Common::isPhpCliMode()) { + exit; +} + +$piwikHostname = CronArchive::getParameterFromCli('piwik-domain', true); +$piwikHostname = Url::getHostFromUrl($piwikHostname); +Url::setHost($piwikHostname); + +// load active plugins +$pluginsManager = Plugin\Manager::getInstance(); +$pluginsToLoad = Config::getInstance()->Plugins['Plugins']; $pluginsManager->loadPlugins($pluginsToLoad); -if (!Piwik\Common::isPhpCliMode()) { - exit; -} -$console = new Piwik\Console(); +$console = new Console(); $console->run();
\ No newline at end of file diff --git a/core/Console.php b/core/Console.php index 54bfcc0938..410ffa5eb7 100644 --- a/core/Console.php +++ b/core/Console.php @@ -9,6 +9,7 @@ namespace Piwik; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputOption; class Console @@ -17,7 +18,6 @@ class Console { $console = new Application(); $option = new InputOption('piwik-domain', null, InputOption::VALUE_OPTIONAL, 'Piwik URL (protocol and domain) eg. "http://piwik.example.org"'); - $console->getDefinition()->addOption($option); $commands = $this->getAvailableCommands(); diff --git a/core/CronArchive.php b/core/CronArchive.php index 972037a8c6..bf1a7b0b4b 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -433,7 +433,7 @@ Notes: public function runScheduledTasks() { $this->logSection("SCHEDULED TASKS"); - if($this->isParameterSet('--disable-scheduled-tasks')) { + if($this->getParameterFromCli('--disable-scheduled-tasks')) { $this->log("Scheduled tasks are disabled with --disable-scheduled-tasks"); return; } @@ -492,7 +492,7 @@ Notes: $dateLast = $dateLastMax; } - $dateLastForced = $this->isParameterSet('--force-date-last-n', true); + $dateLastForced = $this->getParameterFromCli('--force-date-last-n', true); if(!empty($dateLastForced)){ $dateLast = $dateLastForced; } @@ -724,7 +724,7 @@ Notes: private function displayHelp() { - $displayHelp = $this->isParameterSet('help') || $this->isParameterSet('h'); + $displayHelp = $this->getParameterFromCli('help') || $this->getParameterFromCli('h'); if ($displayHelp) { $this->usage(); @@ -739,12 +739,12 @@ Notes: private function initStateFromParameters() { $this->todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive(); - $this->acceptInvalidSSLCertificate = $this->isParameterSet("accept-invalid-ssl-certificate"); + $this->acceptInvalidSSLCertificate = $this->getParameterFromCli("accept-invalid-ssl-certificate"); $this->processPeriodsMaximumEverySeconds = $this->getDelayBetweenPeriodsArchives(); - $this->shouldArchiveAllSites = (bool) $this->isParameterSet("force-all-websites"); - $this->shouldStartProfiler = (bool) $this->isParameterSet("xhprof"); - $restrictToIdSites = $this->isParameterSet("force-idsites", true); - $skipIdSites = $this->isParameterSet("skip-idsites", true); + $this->shouldArchiveAllSites = (bool) $this->getParameterFromCli("force-all-websites"); + $this->shouldStartProfiler = (bool) $this->getParameterFromCli("xhprof"); + $restrictToIdSites = $this->getParameterFromCli("force-idsites", true); + $skipIdSites = $this->getParameterFromCli("skip-idsites", true); $this->shouldArchiveSpecifiedSites = \Piwik\Site::getIdSitesFromIdSitesString($restrictToIdSites); $this->shouldSkipSpecifiedSites = \Piwik\Site::getIdSitesFromIdSitesString($skipIdSites); $this->lastSuccessRunTimestamp = Option::get(self::OPTION_ARCHIVING_FINISHED_TS); @@ -835,7 +835,7 @@ Notes: } } else { // If archive.php run as CLI/shell we require the piwik url to be set - $piwikUrl = $this->isParameterSet("url", true); + $piwikUrl = $this->getParameterFromCli("url", true); if (!$piwikUrl) { $this->logFatalErrorUrlExpected(); @@ -877,7 +877,7 @@ Notes: * @param bool $valuePossible * @return true or the value (int,string) if set, false otherwise */ - private function isParameterSet($parameter, $valuePossible = false) + public static function getParameterFromCli($parameter, $valuePossible = false) { if (!Common::isPhpCliMode()) { return false; @@ -1040,7 +1040,7 @@ Notes: */ private function getDelayBetweenPeriodsArchives() { - $forceTimeoutPeriod = $this->isParameterSet("force-timeout-for-periods", $valuePossible = true); + $forceTimeoutPeriod = $this->getParameterFromCli("force-timeout-for-periods", $valuePossible = true); if (empty($forceTimeoutPeriod) || $forceTimeoutPeriod === true) { return self::SECONDS_DELAY_BETWEEN_PERIOD_ARCHIVES; } @@ -1058,7 +1058,7 @@ Notes: private function isShouldArchiveAllSitesWithTrafficSince() { - $shouldArchiveAllPeriodsSince = $this->isParameterSet("force-all-periods", $valuePossible = true); + $shouldArchiveAllPeriodsSince = $this->getParameterFromCli("force-all-periods", $valuePossible = true); if(empty($shouldArchiveAllPeriodsSince)) { return false; } diff --git a/core/Url.php b/core/Url.php index 0aa5e88590..34b1175dfc 100644 --- a/core/Url.php +++ b/core/Url.php @@ -441,6 +441,9 @@ class Url static public function getHostFromUrl($url) { + if(!UrlHelper::isLookLikeUrl($url)) { + $url = "http://" . $url; + } return parse_url($url, PHP_URL_HOST); } diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI -Subproject bd346cd1f74ca62490092aecfb631471ae01abd +Subproject 36e78b502adca3050885cbc0ccb9ea9e9964bff |