作者:jos
项目:CGE-File-Sharin
/**
* Called on Core install, update, plugin enable/disable
* Will clear all cache that could be affected by the change in configuration being made
*/
public static function deleteAllCacheOnUpdate($pluginName = false)
{
AssetManager::getInstance()->removeMergedAssets($pluginName);
View::clearCompiledTemplates();
Cache::deleteTrackerCache();
self::clearPhpCaches();
}
作者:carriercom
项目:piwi
public function testGetMaxCustomVariables_ShouldReadFromCacheIfPossible()
{
$cache = Cache::getCacheGeneral();
$cache['CustomVariables.MaxNumCustomVariables'] = 10;
Cache::setCacheGeneral($cache);
$this->assertSame(10, CustomVariables::getMaxCustomVariables());
}
作者:brienomatt
项目:elmsl
protected function execute(InputInterface $input, OutputInterface $output)
{
$numVarsToSet = $this->getNumVariablesToSet($input);
$numChangesToPerform = $this->getNumberOfChangesToPerform($numVarsToSet);
if (0 === $numChangesToPerform) {
$this->writeSuccessMessage($output, array('Your Piwik is already configured for ' . $numVarsToSet . ' custom variables.'));
return;
}
$output->writeln('');
$output->writeln(sprintf('Configuring Piwik for %d custom variables', $numVarsToSet));
foreach (Model::getScopes() as $scope) {
$this->printChanges($scope, $numVarsToSet, $output);
}
if (!$this->confirmChange($output)) {
return;
}
$output->writeln('');
$output->writeln('Starting to apply changes');
$output->writeln('');
$this->progress = $this->initProgress($numChangesToPerform, $output);
foreach (Model::getScopes() as $scope) {
$this->performChange($scope, $numVarsToSet, $output);
}
Cache::clearCacheGeneral();
$this->progress->finish();
$this->writeSuccessMessage($output, array('Your Piwik is now configured for ' . $numVarsToSet . ' custom variables.'));
}
作者:bossrabbi
项目:piwi
public function onSiteDeleted($idSite)
{
// we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
Cache::deleteCacheWebsiteAttributes($idSite);
$archiveInvalidator = new ArchiveInvalidator();
$archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
}
作者:KiwiJuice
项目:handball-dacha
static function update($schema = 'Myisam')
{
// force regeneration of cache files following #648
Piwik::setUserIsSuperUser();
$allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
作者:cem
项目:piwi
/**
* 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');
}
作者:piwi
项目:piwi
public function onSiteDeleted($idSite)
{
// we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
Cache::deleteCacheWebsiteAttributes($idSite);
$archiveInvalidator = StaticContainer::get('Piwik\\Archive\\ArchiveInvalidator');
$archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
MeasurableSettingsTable::removeAllSettingsForSite($idSite);
}
作者:mgou-ne
项目:piwi
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
Cache::deleteTrackerCache();
$_SERVER['HTTP_USER_AGENT'] = '';
}
作者:dorelljame
项目:piwi
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
Cache::deleteTrackerCache();
$this->request = $this->buildRequest(array('idsite' => '1'));
}
作者:jos
项目:CGE-File-Sharin
public static function getGoalDefinitions($idSite)
{
$websiteAttributes = Cache::getCacheWebsiteAttributes($idSite);
if (isset($websiteAttributes['goals'])) {
return $websiteAttributes['goals'];
}
return array();
}
作者:Michael2008
项目:piwi
public function onSiteDeleted($idSite)
{
// we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
Cache::deleteCacheWebsiteAttributes($idSite);
$archiveInvalidator = StaticContainer::get('Piwik\\Archive\\ArchiveInvalidator');
$archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
$measurableStorage = new Storage(Db::get(), $idSite);
$measurableStorage->deleteAllValues();
}
作者:FluentDevelopmen
项目:piwi
public function test_storageCreateACacheEntryIfNoCacheExistsYet()
{
$cache = Cache::getCacheGeneral();
$this->assertArrayNotHasKey('settingsStorage', $cache);
// make sure there is no cache entry yet
$this->setSettingValueAndMakeSureCacheGetsCreated('myVal');
$cache = $this->getCache()->fetch($this->storage->getOptionKey());
$this->assertEquals(array($this->setting->getKey() => 'myVal'), $cache);
}
作者:a4tunad
项目:piwi
protected function sendRequest($url, $method = 'GET', $data = null, $force = false)
{
// if doing a bulk request, store the url
if ($this->doBulkRequests && !$force) {
$this->storedTrackingActions[] = $url;
return true;
}
if ($method == 'POST') {
$requests = array();
foreach ($this->storedTrackingActions as $action) {
$requests[] = $this->parseUrl($action);
}
$testEnvironmentArgs = array();
} else {
$testEnvironmentArgs = $this->parseUrl($url);
$requests = array($testEnvironmentArgs);
}
// unset cached values
Cache::$trackerCache = null;
Tracker::setForceIp(null);
Tracker::setForceDateTime(null);
// save some values
$plugins = Config::getInstance()->Plugins['Plugins'];
$oldTrackerConfig = Config::getInstance()->Tracker;
\Piwik\Plugin\Manager::getInstance()->unloadPlugins();
// modify config
$GLOBALS['PIWIK_TRACKER_MODE'] = true;
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = true;
Tracker::$initTrackerMode = false;
Tracker::setTestEnvironment($testEnvironmentArgs, $method);
// set language
$oldLang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $this->acceptLanguage;
// set user agent
$oldUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$_SERVER['HTTP_USER_AGENT'] = $this->userAgent;
// set cookie
$oldCookie = $_COOKIE;
// parse_str(parse_url($this->requestCookie, PHP_URL_QUERY), $_COOKIE);
// do tracking and capture output
ob_start();
$localTracker = new Tracker();
$localTracker->main($requests);
$output = ob_get_contents();
ob_end_clean();
// restore vars
Config::getInstance()->Tracker = $oldTrackerConfig;
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $oldLang;
$_SERVER['HTTP_USER_AGENT'] = $oldUserAgent;
$_COOKIE = $oldCookie;
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = false;
$GLOBALS['PIWIK_TRACKER_MODE'] = false;
unset($_GET['bots']);
// reload plugins
\Piwik\Plugin\Manager::getInstance()->loadPlugins($plugins);
return $output;
}
作者:brienomatt
项目:elmsl
private function set($name, $value, $config)
{
if ('boolean' == $config['type']) {
$value = $value ? '1' : '0';
} else {
settype($value, $config['type']);
}
Option::set($this->prefix($name), $value);
Cache::clearCacheGeneral();
}
作者:FluentDevelopmen
项目:piwi
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Tracker\Cache::deleteTrackerCache();
$this->response = new Response();
$this->handler = new Handler();
$this->handler->setResponse($this->response);
$this->tracker = new Tracker();
$this->requestSet = new RequestSet();
}
作者:ruchitram
项目:plugin-QueuedTrackin
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createSuperUser();
Tracker\Cache::deleteTrackerCache();
$this->backend = $this->createRedisBackend();
$this->queue = Queue\Factory::makeQueueManager($this->backend);
$this->response = new Response();
$this->handler = new Handler();
$this->handler->setResponse($this->response);
$this->tracker = new Tracker();
$this->requestSet = new RequestSet();
}
作者:piwi
项目:plugin-CustomDimension
public function setUp()
{
parent::setUp();
if (!Fixture::siteCreated(1)) {
Fixture::createWebsite('2012-01-01 00:00:00');
}
if (!Fixture::siteCreated(2)) {
Fixture::createWebsite('2012-01-01 00:00:00');
}
Cache::clearCacheGeneral();
Cache::deleteCacheWebsiteAttributes($idSite = 1);
Cache::deleteCacheWebsiteAttributes($idSite = 2);
$this->processor = new Processor();
}
作者:ep12
项目:plugin-CustomDimension
private function configureSomeDimensions()
{
$configuration = new Configuration();
$configuration->configureNewDimension($this->idSite, 'MyName1', CustomDimensions::SCOPE_VISIT, 1, $active = true, $extractions = array(), $caseSensitive = true);
$configuration->configureNewDimension($this->idSite, 'MyName2', CustomDimensions::SCOPE_VISIT, 2, $active = true, $extractions = array(), $caseSensitive = true);
$configuration->configureNewDimension($this->idSite2, 'MyName1', CustomDimensions::SCOPE_VISIT, 1, $active = true, $extractions = array(), $caseSensitive = true);
$extraction1 = new Extraction('urlparam', 'test');
$extraction2 = new Extraction('urlparam', 'param');
$extraction3 = new Extraction('url', '/sub_(.{2})/page');
$configuration->configureNewDimension($this->idSite, 'MyName3', CustomDimensions::SCOPE_ACTION, 1, $active = true, $extractions = array($extraction3->toArray()), $caseSensitive = true);
$configuration->configureNewDimension($this->idSite, 'MyName4', CustomDimensions::SCOPE_ACTION, 2, $active = false, $extractions = array(), $caseSensitive = true);
$configuration->configureNewDimension($this->idSite, 'MyName5', CustomDimensions::SCOPE_ACTION, 3, $active = true, $extractions = array($extraction1->toArray(), $extraction2->toArray()), $caseSensitive = true);
$configuration->configureNewDimension($this->idSite, 'MyName6', CustomDimensions::SCOPE_VISIT, 4, $active = true, $extractions = array(), $caseSensitive = true);
Cache::deleteCacheWebsiteAttributes(1);
Cache::deleteCacheWebsiteAttributes(2);
Cache::clearCacheGeneral();
}
作者:brienomatt
项目:elmsl
public static function getMaxCustomVariables()
{
$cache = Cache::getCacheGeneral();
$cacheKey = 'CustomVariables.MaxNumCustomVariables';
if (!array_key_exists($cacheKey, $cache)) {
$maxCustomVar = 0;
foreach (Model::getScopes() as $scope) {
$model = new Model($scope);
$highestIndex = $model->getHighestCustomVarIndex();
if ($highestIndex > $maxCustomVar) {
$maxCustomVar = $highestIndex;
}
}
$cache[$cacheKey] = $maxCustomVar;
Cache::setCacheGeneral($cache);
}
return $cache[$cacheKey];
}
作者:carriercom
项目:piwi
static function update()
{
$obsoleteFiles = array(PIWIK_INCLUDE_PATH . '/core/Db/Mysqli.php');
foreach ($obsoleteFiles as $obsoleteFile) {
if (file_exists($obsoleteFile)) {
@unlink($obsoleteFile);
}
}
$obsoleteDirectories = array(PIWIK_INCLUDE_PATH . '/core/Db/Pdo');
foreach ($obsoleteDirectories as $dir) {
if (file_exists($dir)) {
Filesystem::unlinkRecursive($dir, true);
}
}
// force regeneration of cache files
Piwik::setUserHasSuperUserAccess();
$allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}