piwik/core/Tracker/ScheduledTasksRunner.php
/**
     * 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
     */
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
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();
        $minimumInterval = TrackerConfig::getConfigValue('scheduled_tasks_min_interval');
        $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);
            Tracker::initCorePiwikInTrackerMode();
            Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']);
            Common::printDebug('-> Scheduled Tasks: Starting...');
            $isSuperUser = Piwik::hasUserSuperUserAccess();
            Piwik::setUserHasSuperUserAccess();
            ob_start();
            CronArchive::$url = SettingsPiwik::getPiwikUrl();
            $cronArchive = new CronArchive();
            $cronArchive->runScheduledTasksInTrackerMode();
            $resultTasks = ob_get_contents();
            ob_clean();
            Piwik::setUserHasSuperUserAccess($isSuperUser);
            foreach (explode('</pre>', $resultTasks) as $resultTask) {
                Common::printDebug(str_replace('<pre>', '', $resultTask));
            }
            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 runScheduledTasks ( ) { $ now = time ( ) ; $ minimumInterval = TrackerConfig :: getConfigValue ( 'scheduled_tasks_min_interval' ) ; $ 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 ) ; Tracker :: initCorePiwikInTrackerMode ( ) ; Option :: set ( 'lastTrackerCronRun' , $ cache [ 'lastTrackerCronRun' ] ) ; Common :: printDebug ( '-> Scheduled Tasks: Starting...' ) ; $ isSuperUser = Piwik :: hasUserSuperUserAccess ( ) ; Piwik :: setUserHasSuperUserAccess ( ) ; ob_start ( ) ; CronArchive :: $ url = SettingsPiwik :: getPiwikUrl ( ) ; $ cronArchive = new CronArchive ( ) ; $ cronArchive -> runScheduledTasksInTrackerMode ( ) ; $ resultTasks = ob_get_contents ( ) ; ob_clean ( ) ; Piwik :: setUserHasSuperUserAccess ( $ isSuperUser ) ; foreach ( explode ( '</pre>' , $ resultTasks ) as $ resultTask ) { Common :: printDebug ( str_replace ( '<pre>' , '' , $ resultTask ) ) ; } 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' ) ; }
Tracker requests will automatically trigger the Scheduled tasks.
Tracker requests will automatically trigger the Scheduled tasks .
// 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) // 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 // save current user privilege and temporarily assume Super User privilege // Scheduled tasks assume Super User is running // restore original user privilege