private function handleGeneralSettingsAdmin($view) { // Whether to display or not the general settings (cron, beta, smtp) $view->isGeneralSettingsAdminEnabled = self::isGeneralSettingsAdminEnabled(); if ($view->isGeneralSettingsAdminEnabled) { $this->displayWarningIfConfigFileNotWritable(); } $enableBrowserTriggerArchiving = Rules::isBrowserTriggerEnabled(); $todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive(); $showWarningCron = false; if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) { $showWarningCron = true; } $view->showWarningCron = $showWarningCron; $view->todayArchiveTimeToLive = $todayArchiveTimeToLive; $view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving; $view->enableBetaReleaseCheck = Config::getInstance()->Debug['allow_upgrades_to_beta']; $view->mail = Config::getInstance()->mail; $pluginUpdateCommunication = new UpdateCommunication(); $view->canUpdateCommunication = $pluginUpdateCommunication->canBeEnabled(); $view->enableSendPluginUpdateCommunication = $pluginUpdateCommunication->isEnabled(); }
/** * test of validity of an archive, for today's archive with toronto's timezone * @group Core */ public function testInitTodayToronto() { if (!SettingsServer::isTimezoneSupportEnabled()) { $this->markTestSkipped('timezones needs to be supported'); } $now = time(); $siteTimezone = 'America/Toronto'; $timestamp = Date::factory('now', $siteTimezone)->getTimestamp(); $dateLabel = date('Y-m-d', $timestamp); Rules::setBrowserTriggerArchiving(true); $archiveProcessor = $this->_createArchiveProcessor('day', $dateLabel, $siteTimezone); $archiveProcessor->time = $now; // we look at anything processed within the time to live range $dateMinArchived = $now - Rules::getTodayArchiveTimeToLive(); $this->compareTimestamps($dateMinArchived, $archiveProcessor->public_getMinTimeArchiveProcessed()); $this->assertTrue($archiveProcessor->public_isArchiveTemporary()); // when browsers don't trigger archives... Rules::setBrowserTriggerArchiving(false); // ...we force ArchiveProcessor to fetch any of the most recent archive $dateMinArchived = false; $this->compareTimestamps($dateMinArchived, $archiveProcessor->public_getMinTimeArchiveProcessed()); // this test varies with DST $this->assertTrue($archiveProcessor->getParams()->getDateStart()->getDateStartUTC() == date('Y-m-d', $timestamp) . ' 04:00:00' || $archiveProcessor->getParams()->getDateStart()->getDateStartUTC() == date('Y-m-d', $timestamp) . ' 05:00:00'); $this->assertTrue($archiveProcessor->getParams()->getDateEnd()->getDateEndUTC() == date('Y-m-d', $timestamp + 86400) . ' 03:59:59' || $archiveProcessor->getParams()->getDateEnd()->getDateEndUTC() == date('Y-m-d', $timestamp + 86400) . ' 04:59:59'); $this->assertTrue($archiveProcessor->public_isArchiveTemporary()); }
/** * Returns a timestamp indicating outdated archives older than this timestamp (processed before) can be purged. * * @return int|bool Outdated archives older than this timestamp should be purged */ protected function getOldestTemporaryArchiveToKeepThreshold() { $temporaryArchivingTimeout = Rules::getTodayArchiveTimeToLive(); if (Rules::isBrowserTriggerEnabled()) { // If Browser Archiving is enabled, it is likely there are many more temporary archives // We delete more often which is safe, since reports are re-processed on demand return Date::factory($this->now - 2 * $temporaryArchivingTimeout)->getDateTime(); } // If cron core:archive command is building the reports, we should keep all temporary reports from today return $this->yesterday->getDateTime(); }
/** * Initializes the various parameters to the script, based on input parameters. * */ private function initStateFromParameters() { $this->todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive(); $this->processPeriodsMaximumEverySeconds = $this->getDelayBetweenPeriodsArchives(); $this->lastSuccessRunTimestamp = $this->getLastSuccessRunTimestamp(); $this->shouldArchiveOnlySitesWithTrafficSince = $this->isShouldArchiveAllSitesWithTrafficSince(); $this->shouldArchiveOnlySpecificPeriods = $this->getPeriodsToProcess(); if ($this->shouldArchiveOnlySitesWithTrafficSince !== false) { // force-all-periods is set here $this->archiveAndRespectTTL = false; } }
public static function getMinTimeProcessedForTemporaryArchive(Date $dateStart, \Piwik\Period $period, Segment $segment, Site $site) { $now = time(); $minimumArchiveTime = $now - Rules::getTodayArchiveTimeToLive(); $idSites = array($site->getId()); $isArchivingDisabled = Rules::isArchivingDisabledFor($idSites, $segment, $period->getLabel()); if ($isArchivingDisabled) { if ($period->getNumberOfSubperiods() == 0 && $dateStart->getTimestamp() <= $now) { // Today: accept any recent enough archive $minimumArchiveTime = false; } else { // This week, this month, this year: // accept any archive that was processed today after 00:00:01 this morning $timezone = $site->getTimezone(); $minimumArchiveTime = Date::factory(Date::factory('now', $timezone)->getDateStartUTC())->setTimezone($timezone)->getTimestamp(); } } return $minimumArchiveTime; }
/** * Initializes the various parameters to the script, based on input parameters. * */ private function initStateFromParameters() { $this->todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive(); $this->processPeriodsMaximumEverySeconds = $this->getDelayBetweenPeriodsArchives(); $this->lastSuccessRunTimestamp = Option::get(self::OPTION_ARCHIVING_FINISHED_TS); $this->shouldArchiveOnlySitesWithTrafficSince = $this->isShouldArchiveAllSitesWithTrafficSince(); $this->shouldArchiveOnlySpecificPeriods = $this->getPeriodsToProcess(); if ($this->shouldArchiveOnlySitesWithTrafficSince === false) { // force-all-periods is not set here if (empty($this->lastSuccessRunTimestamp)) { // First time we run the script $this->shouldArchiveOnlySitesWithTrafficSince = self::ARCHIVE_SITES_WITH_TRAFFIC_SINCE; } else { // there was a previous successful run $this->shouldArchiveOnlySitesWithTrafficSince = time() - $this->lastSuccessRunTimestamp; } } else { // force-all-periods is set here $this->archiveAndRespectTTL = false; if ($this->shouldArchiveOnlySitesWithTrafficSince === true) { // force-all-periods without value $this->shouldArchiveOnlySitesWithTrafficSince = self::ARCHIVE_SITES_WITH_TRAFFIC_SINCE; } } }
private function handleGeneralSettingsAdmin($view) { // Whether to display or not the general settings (cron, beta, smtp) $view->isGeneralSettingsAdminEnabled = self::isGeneralSettingsAdminEnabled(); if ($view->isGeneralSettingsAdminEnabled) { $this->displayWarningIfConfigFileNotWritable(); } $enableBrowserTriggerArchiving = Rules::isBrowserTriggerEnabled(); $todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive(); $showWarningCron = false; if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) { $showWarningCron = true; } $view->showWarningCron = $showWarningCron; $view->todayArchiveTimeToLive = $todayArchiveTimeToLive; $view->todayArchiveTimeToLiveDefault = Rules::getTodayArchiveTimeToLiveDefault(); $view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving; $releaseChannels = $this->makeReleaseChannels(); $activeChannelId = $releaseChannels->getActiveReleaseChannel()->getId(); $allChannels = array(); foreach ($releaseChannels->getAllReleaseChannels() as $channel) { $allChannels[] = array('id' => $channel->getId(), 'name' => $channel->getName(), 'description' => $channel->getDescription(), 'active' => $channel->getId() === $activeChannelId); } $view->releaseChannels = $allChannels; $view->mail = Config::getInstance()->mail; $pluginUpdateCommunication = new UpdateCommunication(); $view->canUpdateCommunication = $pluginUpdateCommunication->canBeEnabled(); $view->enableSendPluginUpdateCommunication = $pluginUpdateCommunication->isEnabled(); }
/** * Initializes the various parameters to the script, based on input parameters. * */ private function initStateFromParameters() { $this->todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive(); $this->acceptInvalidSSLCertificate = $this->getParameterFromCli("accept-invalid-ssl-certificate"); $this->processPeriodsMaximumEverySeconds = $this->getDelayBetweenPeriodsArchives(); $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); $this->shouldArchiveOnlySitesWithTrafficSince = $this->isShouldArchiveAllSitesWithTrafficSince(); $this->shouldArchiveOnlySpecificPeriods = $this->getPeriodsToProcess(); if ($this->shouldArchiveOnlySitesWithTrafficSince === false) { // force-all-periods is not set here if (empty($this->lastSuccessRunTimestamp)) { // First time we run the script $this->shouldArchiveOnlySitesWithTrafficSince = self::ARCHIVE_SITES_WITH_TRAFFIC_SINCE; } else { // there was a previous successful run $this->shouldArchiveOnlySitesWithTrafficSince = time() - $this->lastSuccessRunTimestamp; } } else { // force-all-periods is set here $this->archiveAndRespectTTL = false; if ($this->shouldArchiveOnlySitesWithTrafficSince === true) { // force-all-periods without value $this->shouldArchiveOnlySitesWithTrafficSince = self::ARCHIVE_SITES_WITH_TRAFFIC_SINCE; } } }
private function handleGeneralSettingsAdmin($view) { // Whether to display or not the general settings (cron, beta, smtp) $view->isGeneralSettingsAdminEnabled = self::isGeneralSettingsAdminEnabled(); if ($view->isGeneralSettingsAdminEnabled) { $this->displayWarningIfConfigFileNotWritable(); } $enableBrowserTriggerArchiving = Rules::isBrowserTriggerEnabled(); $todayArchiveTimeToLive = Rules::getTodayArchiveTimeToLive(); $showWarningCron = false; if (!$enableBrowserTriggerArchiving && $todayArchiveTimeToLive < 3600) { $showWarningCron = true; } $view->showWarningCron = $showWarningCron; $view->todayArchiveTimeToLive = $todayArchiveTimeToLive; $view->todayArchiveTimeToLiveDefault = Rules::getTodayArchiveTimeToLiveDefault(); $view->enableBrowserTriggerArchiving = $enableBrowserTriggerArchiving; $view->mail = Config::getInstance()->mail; }