/** * Tracker requests will automatically trigger the Scheduled tasks. * This is useful for users who don't setup the cron, * but still want daily/weekly/monthly PDF reports emailed automatically. * * This is similar to calling the API CoreAdminHome.runScheduledTasks */ public function runScheduledTasks() { $now = time(); // Currently, there are no hourly tasks. When there are some, // this could be too aggressive minimum interval (some hours would be skipped in case of low traffic) $minimumInterval = TrackerConfig::getConfigValue('scheduled_tasks_min_interval'); // If the user disabled browser archiving, he has already setup a cron // To avoid parallel requests triggering the Scheduled Tasks, // Get last time tasks started executing $cache = Cache::getCacheGeneral(); if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerEnabled'])) { Common::printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled."); return; } $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval; if (defined('DEBUG_FORCE_SCHEDULED_TASKS') && DEBUG_FORCE_SCHEDULED_TASKS || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) { $cache['lastTrackerCronRun'] = $now; Cache::setCacheGeneral($cache); Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']); Common::printDebug('-> Scheduled Tasks: Starting...'); $invokeScheduledTasksUrl = "?module=API&format=csv&convertToUnicode=0&method=CoreAdminHome.runScheduledTasks&trigger=archivephp"; $cliMulti = new CliMulti(); $cliMulti->runAsSuperUser(); $responses = $cliMulti->request(array($invokeScheduledTasksUrl)); $resultTasks = reset($responses); Common::printDebug($resultTasks); Common::printDebug('Finished Scheduled Tasks.'); } else { Common::printDebug("-> Scheduled tasks not triggered."); } Common::printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC'); }
public function test_requiresAuthentication_shouldReturnFalse_IfDisabled() { $oldConfig = TrackerConfig::getConfigValue('bulk_requests_require_authentication'); TrackerConfig::setConfigValue('bulk_requests_require_authentication', 0); $this->assertFalse($this->requests->requiresAuthentication()); TrackerConfig::setConfigValue('bulk_requests_require_authentication', $oldConfig); }
public function test_isAuthenticated_ShouldBeAuthenticatedIfCheckIsDisabledInConfig() { $oldConfig = TrackerConfig::getConfigValue('tracking_requests_require_authentication'); TrackerConfig::setConfigValue('tracking_requests_require_authentication', 0); $this->assertTrue($this->request->isAuthenticated()); TrackerConfig::setConfigValue('tracking_requests_require_authentication', $oldConfig); }
/** * @return bool */ private function isTransactionSupported() { return (bool) TrackerConfig::getConfigValue('bulk_requests_use_transaction'); }
public function test_loadTrackerEnvironment_shouldSetGlobalsDebugVar() { $this->assertTrue(!array_key_exists('PIWIK_TRACKER_DEBUG', $GLOBALS)); $oldConfig = Tracker\TrackerConfig::getConfigValue('debug'); Tracker\TrackerConfig::setConfigValue('debug', 1); Tracker::loadTrackerEnvironment(); $this->assertTrue($this->tracker->isDebugModeEnabled()); Tracker\TrackerConfig::setConfigValue('debug', $oldConfig); // reset $this->assertTrue($GLOBALS['PIWIK_TRACKER_DEBUG']); }
private static function notifyWhenDebugOnDemandIsEnabled($trackerSetting) { if (!Development::isEnabled() && Piwik::hasUserSuperUserAccess() && TrackerConfig::getConfigValue($trackerSetting)) { $message = Piwik::translate('General_WarningDebugOnDemandEnabled'); $message = sprintf($message, '"' . $trackerSetting . '"', '"[Tracker] ' . $trackerSetting . '"', '"0"', '"config/config.ini.php"'); $notification = new Notification($message); $notification->title = Piwik::translate('General_Warning'); $notification->priority = Notification::PRIORITY_LOW; $notification->context = Notification::CONTEXT_WARNING; $notification->type = Notification::TYPE_TRANSIENT; $notification->flags = Notification::FLAG_NO_CLEAR; NotificationManager::notify('Tracker' . $trackerSetting, $notification); } }
protected function getCookiePath() { return TrackerConfig::getConfigValue('cookie_path'); }
public function __construct() { $this->createNewVisitWhenCampaignChanges = TrackerConfig::getConfigValue('create_new_visit_when_campaign_changes') == 1; }
private static function isDebugEnabled() { try { $debug = (bool) TrackerConfig::getConfigValue('debug'); if ($debug) { return true; } $debugOnDemand = (bool) TrackerConfig::getConfigValue('debug_on_demand'); if ($debugOnDemand) { return (bool) Common::getRequestVar('debug', false); } } catch (Exception $e) { } return false; }
public function test_getCookiePath_ShouldReturnConfigValue() { $oldPath = TrackerConfig::getConfigValue('cookie_path'); TrackerConfig::setConfigValue('cookie_path', 'test'); $this->assertEquals('test', $this->request->getCookiePath()); TrackerConfig::setConfigValue('cookie_path', $oldPath); }
public function requiresAuthentication() { $requiresAuth = TrackerConfig::getConfigValue('bulk_requests_require_authentication'); return !empty($requiresAuth); }
public function __construct() { $this->createNewVisitWhenWebsiteReferrerChanges = TrackerConfig::getConfigValue('create_new_visit_when_website_referrer_changes') == 1; }
public function test_process_shouldNotProcessAnything_IfRecordStatisticsIsDisabled() { $this->addRequestSetsToQueue(8); $record = TrackerConfig::getConfigValue('record_statistics'); TrackerConfig::setConfigValue('record_statistics', 0); $tracker = $this->process(); TrackerConfig::setConfigValue('record_statistics', $record); $this->assertSame(0, $tracker->getCountOfLoggedRequests()); $this->assertSame(8, $this->queue->getNumberOfRequestSetsInAllQueues()); }